I am making a game for a school project and I ran into a weird bug. When I go through my Level 1 (The Boat) and fail, and then I select the other Level (The Wagon), the screen derps out and is really weird. does anyone know how to fix this?
Here is the code:
REM Project: Test 2
REM Created: 1/7/2014 8:00:08 AM
REM
REM ***** Main Source File *****
REM
autocam on
hide mouse
center text 320,240, "Welcome to the Game! Press Any key to continue!"
do
REM CONTROL INPUT
key=scancode() : if Keystate(key)=1 then gosub Story
sync
loop
Story:
cls 0
Center text 320,240, "Welcome to INSERT NAME HERE!"
center text 320,260, "You are a poor man who lives in the east"
center text 320,280, "You heard news of gold in California and you want to go"
center text 320,300, "You can either go by boat or by wagon!"
center text 320,320, "Press "A" to continue"
do
if Inkey$()="a" then gosub Selection
sync
loop
Selection:
cls
center text 320,240, "Press S to go by BOAT or D to go by WAGON"
do
if inkey$()="s" then gosub Level1
if Inkey$()="d" then gosub Level2
sync
loop
Level1:
cls 0
load image "E:\Advanced Tech\BlueOcean.jpg",1
load image "E:\Advanced Tech\land.jpg",2
load image "E:\Advanced Tech\Carbonade\port.jpg",3
load image "E:\Doge.jpg",4
cls 0 : backdrop on
make object cube 1,100
scale object 1,100,140,100
texture object 1,4
make object box 3,100000,2000,10
rotate object 3,0,90,0
position object 3,2005,500,0
texture object 3,1
make object box 5,100000,2000,10
rotate object 5,0,270,0
position object 5, -2005,500,0
texture object 5,1
make object box 4,5000,1000,10
rotate object 4,0,180,0
position object 4, -50,0,-1005
rem north wall
make object box 9000,5000,1000,10
rotate object 9000,0,180,0
position object 9000,-50,300,50000
texture object 9000,3
RockNumber = 150
for t = 1 to RockNumber
make object sphere t + RockNumber ,200
x= rnd(2000)-rnd(2000)
y= 1
z= rnd(50000)-rnd(50000)
position object t + RockNumber,x,y,z,
make object collision box t + RockNumber ,-25,-25,-25,25,25,25,1
next t
position camera -100,100,-100
point camera 0,20,0
yrotate camera -90
do
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
A1X = object angle X(1)
A1Y = object angle Y(1)
A1Z = object angle Z(1)
BoatSpeed=3
Collision=0
set cursor 0,20
print "X ";P1X#
print "Y ";P1Y#
print "Z ";P1Z#
set camera to follow object position x(1), object position y(1), object position z(1), object angle y(1), 190, 290, 100, 0
move object 1,BoatSpeed
if downkey()=1 then move object 1,-2-BoatSpeed
if Leftkey()=1 then move object left 1,Boatspeed
if Rightkey()=1 then move object right 1,BoatSpeed
if Inkey$()="q"
delete object 1 : backdrop off :
endif
Rem East wall colluision
if object collision (1,3)> 0
Collision = Collision + 1
endif
if Collision > 0
position object 1, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
rem west wall collision
if object collision (1,5)> 0
Collision = Collision + 1
endif
if Collision > 0
position object 1, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
rem south wall collision
if object collision (1,4)>0
Collision= Collision + 1
endif
if Collision > 0
position object 1, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
if object collision (1,9000)>0
gosub EndSection
endif
for t = 1 to RockNumber
if object collision (1, t + RockNumber)>0
gosub Defeat
endif
next t
loop
Level2:
make object cube 10,100
scale object 10,100,140,100
make object box 11,100000,2000,10
rotate object 11,0,90,0
position object 11,2005,500,0
texture object 11,1
make object box 12,100000,2000,10
rotate object 12,0,270,0
position object 12, -2005,500,0
texture object 12,1
make object box 13,5000,1000,10
rotate object 13,0,180,0
position object 13, -50,0,-1005
rem north wall
make object box 9001,5000,1000,10
rotate object 9001,0,180,0
position object 9001,-50,0,50000
LogNumber = 150
for t = 1 to LogNumber
make object cylinder t + LogNumber ,200
x= rnd(2000)-rnd(2000)
y= 1
z= rnd(50000)-rnd(50000)
position object t + LogNumber,x,y,z,
make object collision box t + LogNumber ,-50,-50,-50,50,50,50,1
next t
do
rem Variables
P1X# = object position X(10)
P1Y# = object position Y(10)
P1Z# = object position Z(10)
A1X = object angle X(10)
A1Y = object angle Y(10)
A1Z = object angle Z(10)
WagonSpeed = 3
Collision=0
set cursor 0,20
print "X ";P1X#
print "Y ";P1Y#
print "Z ";P1Z#
rem controls
set camera to follow object position x(10), object position y(10), object position z(10), object angle y(10), 190, 290, 100, 0
move object 10,WagonSpeed
if downkey()=1 then move object 10,-2-WagonSpeed
if Leftkey()=1 then move object left 10,WagonSpeed
if Rightkey()=1 then move object right 10,WagonSpeed
if object collision (10,9001)
gosub EndSection
endif
if object collision (10,11)> 0
Collision = Collision + 1
endif
if Collision > 0
position object 10, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
if object collision (10,12)> 0
Collision = Collision + 1
endif
if Collision > 0
position object 10, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
if object collision (10,13)> 0
Collision = Collision + 1
endif
if Collision > 0
position object 10, P1X#,P1Y#,P1Z# :
endif
if Collision > 1
Collision = Collision - 1
endif
loop
EndSection:
for x = 1 to 10000 : rem Check all the game object
if object exist(x) = 1 then delete object x
next x
backdrop off
cls
center text 320,240, "Congratulations! You have made it to California!"
wait key
end
Defeat:
for x = 1 to 10000 : rem Check all the game object
if object exist(x) = 1 then delete object x
next x
backdrop off
cls
do
center text 320,240, "You messed up. Now you are dead."
Center text 320,260, "Play Again? Y/N"
if keystate(21)=1 then gosub Story
loop
end