does anyone know why when i use the commands:
for q = 1 to 200
if object exist(q) then delete object q
next q
it causes my .exe to just stop working (i get the thing that says .exe has stopped working)
(I'm using this to go to another level and delete the objects from the last level)
heres the whole code if you want it
set display mode 640,480,32,1
sync on
sync rate 60
`Opening Menu
MenuSection:
load image "media\newgamenormal.bmp",1
load image "media\newgameglow.bmp",2
load image "media\controlsnormal.bmp",3
load image "media\controlsglow.bmp",4
load image "media\creditsnormal.bmp",5
load image "media\creditsglow.bmp",6
ButtonX = 220
ButtonY = 100
sprite 1,ButtonX,ButtonY,1 : `New Game
ButtonX1 = 220
ButtonY1 = 226
sprite 2,ButtonX1,ButtonY1,3 : `Controls
ButtonX2 = 220
ButtonY2 = 352
sprite 3,ButtonX2,ButtonY2,5 : `Credits
do
color backdrop 0
if mouseX() > 220 and mouseX() < 420 and MouseY() > 100 and MouseY() < 150
if mouseclick()=1
GOTO GameSection
endif
Glow = 1
else
Glow = 0
endif
if Glow = 0 then sprite 1,ButtonX,ButtonY,1
if Glow = 1 then sprite 1,ButtonX,ButtonY,2
if mouseX() > 220 and mouseX() < 420 and MouseY() > 226 and MouseY() < 276
if mouseclick()=1
GOTO ControlsSection
endif
Glow = 2
else
Glow = 3
endif
if Glow = 3 then sprite 2,ButtonX1,ButtonY1,3
if Glow = 2 then sprite 2,ButtonX1,ButtonY1,4
if mouseX() > 220 and mouseX() < 420 and MouseY() > 352 and MouseY() < 402
Glow = 4
else
Glow = 5
endif
if Glow = 5 then sprite 3,ButtonX2,ButtonY2,5
if Glow = 4 then sprite 3,ButtonX2,ButtonY2,6
sync
loop
`--------------------------------------------------------------------
`--------------------------------------------------------------------
`Controls Section
ControlsSection:
load image "media\controlsback.bmp",9
load image "media\controls1.bmp",10
sprite 10,0,0,10
do
if mouseX() > 500 and mouseX() < 630 and MouseY() > 430 and MouseY() < 470
if mouseclick()=1
delete sprite 10
GOTO MenuSection
endif
Glow = 7
else
Glow = 8
endif
if Glow = 8 then sprite 10,0,0,10
if Glow = 7 then sprite 10,0,0,9
sync
loop
`Game Section
GameSection:
` Init
phy start
sync on : sync rate 60
autocam off : color backdrop 0
set text font "verdana"
set text size 24
`Delete the Menu Sprites
delete sprite 1
delete sprite 2
delete sprite 3
rem Lights and camera
make light 1 : set directional light 1, -5, -5, 5
position camera -20, 20, -25 : point camera 0, 10, 0
rem Load scene
set dir "Scene"
load object "levelbank\level1\level1.dbo",1
position object 1,0,0,0
scale object 1,20,20,20 : phy make rigid body static mesh 1
set dir ".."
`Make box for Dump site
make object box 150,20,6,20
phy make rigid body static mesh 150
phy set rigid body position 150,-41,0,-21
hide object 150
rem Load buggy
load object "beach.x",2
load image "beachbu2.tga",2
load image "dbprocubemap.dds",3
texture object 2,2 : set blend mapping on 2,1,3,2,16
position object 2, 5, 5, -5
offset limb 2,0,0,-0.5,0
rotate limb 2,0,0,-90,0
`Make Countdown
CTtimer = timer()
CTVal = 90
`Make Money Count
rem Create vehicle physics body
width# = 0.75
height# = 0.4
length# = 2.2
wheelX# = 1.1
wheelY# = 0.3
wheelZ# = 1.5
radius# = 0.6
wheelHeight# = 0.2
rem Be aware the vehicle width and length orientation
phy create vehicle 2
phy add vehicle body 2, length#, height#, width#, 0.0, height#, 0.0
phy add vehicle body 2, width#, height#, width#, 0.0, height#*2, 0.0
phy add vehicle wheel 2, 5, wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 0, 0
phy add vehicle wheel 2, 7, wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 2, 3, -wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 1, 0
phy add vehicle wheel 2, 9, -wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
phy set vehicle max motor 2, 200.0
steeringDelta# = 0.1 : phy set vehicle steering delta 2, steeringDelta#
phy set vehicle max steering angle 2, 0.6
phy set vehicle auto 2, 0
phy set vehicle wheel multiplier 2,0
phy set vehicle suspension spring 2,100
phy build vehicle 2
rem follower object invisible
make object sphere 3,10 : hide object 3
rem Particles from exhaust
phy make smoke emitter 4, 32, 10, 5, -10
load image "smoke2.bmp",4
texture object 4, 4
ghost object on 4, 0
rem Simple crates
objid=10 : load object "crate_h.x",10
scale object objid,4,4,8
make mesh from object 10,10
delete object 10
load image "crate_h_d2.dds",10
make object 10,10,10
hide object 10
for y=0 to 9
for z=0 to 7
inc objid : instance object objid,10
position object objid,20,y,-15+(z*3)
phy make rigid body dynamic box objid
phy set rigid body mass objid,5
next z
next y
`CHALLENGE CRATE
rem Some sounds
load sound "Sounds\idle.wav",1 : loop sound 1
load sound "Sounds\bump.wav",2
rem Main
do
`
rem Follow buggy
position object 3,object position x(2),object position y(2),object position z(2)
set object to object orientation 3,2
move object 3,-10
point object 3,object position x(2),object position y(2),object position z(2)
dist#=5.0 : high#=2.5 : angle#=object angle y(3)+90
set camera to follow object position x(2), object position y(2), object position z(2), angle#, dist#, high#, 1, 0
`
rem Control buggy
phy set vehicle motor force 2,0.0
gosub driveCar
`
rem Place exhaust smoke
if boost>1
exy#=object position y(2)
exx#=newxvalue(object position x(2),angle#,-1.0)
exz#=newzvalue(object position z(2),angle#,-1.0)
phy set emitter position 4,exx#,exy#-(abs(boost*0.1)),exz#
else
phy set emitter position 4,-50,-50,50
endif
`
print object position x(150)
print object position z(150)
print object position y(150)
`Make Clock
if Timer() - CTtimer => 1000
Dec CTVal
CTtimer = Timer()
EndIf
print Str$(CTVal)
If CTVal = 0 then end
rem Prompt
center text screen width()/2,30,"ARROWKEYS TO DRIVE SPACE TO BOOST & SELF-RIGHT"
`
rem Update physics and screen
phy update
sync
`
loop
`=========================================================================
`=========================================================================
GameSection2:
` Init
flush video memory
phy start
sync on : sync rate 60
autocam off : color backdrop 0
set text font "verdana"
set text size 24
`Delete the Menu Sprites
rem Lights and camera
position camera -20, 20, -25 : point camera 0, 10, 0
rem Load scene
set dir "Scene"
load object "levelbank\level1\level1.dbo",1
position object 1,0,0,0
scale object 1,20,20,20 : phy make rigid body static mesh 1
set dir ".."
`Make box for Dump site
make object box 150,20,6,20
phy make rigid body static mesh 150
phy set rigid body position 150,-41,0,-21
hide object 150
rem Load buggy
load object "beach.x",2
load image "beachbu2.tga",2
load image "dbprocubemap.dds",3
texture object 2,2 : set blend mapping on 2,1,3,2,16
position object 2, 5, 5, -5
offset limb 2,0,0,-0.5,0
rotate limb 2,0,0,-90,0
`Make Countdown
CTtimer = timer()
CTVal = 90
`Make Money Count
rem Create vehicle physics body
width# = 0.75
height# = 0.4
length# = 2.2
wheelX# = 1.1
wheelY# = 0.3
wheelZ# = 1.5
radius# = 0.6
wheelHeight# = 0.2
rem Be aware the vehicle width and length orientation
phy create vehicle 2
phy add vehicle body 2, length#, height#, width#, 0.0, height#, 0.0
phy add vehicle body 2, width#, height#, width#, 0.0, height#*2, 0.0
phy add vehicle wheel 2, 5, wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 0, 0
phy add vehicle wheel 2, 7, wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 2, 3, -wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 1, 0
phy add vehicle wheel 2, 9, -wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
phy set vehicle max motor 2, 200.0
steeringDelta# = 0.1 : phy set vehicle steering delta 2, steeringDelta#
phy set vehicle max steering angle 2, 0.6
phy set vehicle auto 2, 0
phy set vehicle wheel multiplier 2,0
phy set vehicle suspension spring 2,100
phy build vehicle 2
rem follower object invisible
make object sphere 3,10 : hide object 3
rem Particles from exhaust
phy make smoke emitter 4, 32, 10, 5, -10
load image "smoke2.bmp",4
texture object 4, 4
ghost object on 4, 0
rem Simple crates
objid=10 : load object "crate_h.x",10
scale object objid,4,4,8
make mesh from object 10,10
delete object 10
load image "crate_h_d2.dds",10
make object 10,10,10
hide object 10
for y=0 to 9
for z=0 to 7
inc objid : instance object objid,10
position object objid,20,y,-15+(z*3)
phy make rigid body dynamic box objid
phy set rigid body mass objid,5
next z
next y
`CHALLENGE CRATE
rem Some sounds
load sound "Sounds\idle.wav",1 : loop sound 1
load sound "Sounds\bump.wav",2
rem Main
do
`
rem Follow buggy
position object 3,object position x(2),object position y(2),object position z(2)
set object to object orientation 3,2
move object 3,-10
point object 3,object position x(2),object position y(2),object position z(2)
dist#=5.0 : high#=2.5 : angle#=object angle y(3)+90
set camera to follow object position x(2), object position y(2), object position z(2), angle#, dist#, high#, 1, 0
`
rem Control buggy
phy set vehicle motor force 2,0.0
gosub driveCar
`
rem Place exhaust smoke
if boost>1
exy#=object position y(2)
exx#=newxvalue(object position x(2),angle#,-1.0)
exz#=newzvalue(object position z(2),angle#,-1.0)
phy set emitter position 4,exx#,exy#-(abs(boost*0.1)),exz#
else
phy set emitter position 4,-50,-50,50
endif
`
print object position x(150)
print object position z(150)
print object position y(150)
`Make Clock
if Timer() - CTtimer => 1000
Dec CTVal
CTtimer = Timer()
EndIf
print Str$(CTVal)
If CTVal = 0 then end
rem Prompt
center text screen width()/2,30,"ARROWKEYS TO DRIVE SPACE TO BOOST & SELF-RIGHT"
`
rem Update physics and screen
phy update
sync
`
loop
driveCar:
`
rem movement
key = 0 : force#=0.0
if upkey ( ) = 1
force#=300 : key = 1
endif : phy set vehicle wheel multiplier 2,50
if downkey ( ) = 1 then force#=-250.0 : key = 1 : phy set vehicle wheel multiplier 2,-50
if spacekey ( ) = 1 and boost=0 then boost=30 : forcenoise#=2000.0
if boost>1 then dec boost : force#=1200 : key = 1 : phy set vehicle wheel multiplier 2,200
if spacekey ( ) = 0 and boost=1 then boost=0
if key = 0 then force#=0.0
phy set vehicle motor force 2,force#
if force#>0
forcenoise#=forcenoise#+(force#/10.0)
if forcenoise#>4000.0 then forcenoise#=4000.0
else
if force#<0
forcenoise#=forcenoise#-20.0
if forcenoise#<-500.0 then forcenoise#=-500.0
else
forcenoise#=forcenoise#-50.0
if forcenoise#<0.0 then forcenoise#=0.0
endif
endif
`
rem steering
steeringAngle# = phy get vehicle steering angle ( 2 )
key = 0
if keystate ( 205 ) = 1
if steeringAngle# > ( -1.0 + steeringDelta# )
steeringAngle# = steeringAngle# - ( steeringDelta# / 2 )
endif
key = 1
endif
if keystate ( 203 ) = 1
if steeringAngle# < ( 1.0 - steeringDelta# )
steeringAngle# = steeringAngle# + ( steeringDelta# / 2 )
endif
key = 1
endif
if key = 0
if steeringAngle# > 0.0
steeringAngle# = steeringAngle# - steeringDelta# * 2
if steeringAngle# < 0
steeringAngle# = 0.0
endif
endif
if steeringAngle# < 0.0
steeringAngle# = steeringAngle# + steeringDelta# * 2
if steeringAngle# > 0
steeringAngle# = 0.0
endif
endif
endif
phy set vehicle steering angle 2, steeringAngle#
phy set vehicle steering value 2, -( steeringAngle# * 45 )
`
rem set sound based on vehicle speed
set sound speed 1,18000+(forcenoise#*10)
`
rem collision feedback
zerohit=0
while phy get collision data ( )
c = phy get collision object a ( )
d = phy get collision object b ( )
if (c=150 and d>10) or (d=150 and c>10)
for q = 1 to 200
if object exist(q) then delete object q
next q
wait 500
goto gamesection2
rem buggy object(2) hits any crate object(>10)
if vehiclenothitting=1
forcenoise#=forcenoise#/2.0
end
if sound playing(2)=0 then play sound 2 : set sound speed 2,22000
vehiclenothitting=0
endif
zerohit=1
endif
endwhile
`
return