I've encountered a really weird problem (the strangest I've seen yet!) with my program. I've made it so that when you lose all of your lives, it deletes all of the objects and resets the level. It deletes the objects perfectly fine, but when it resets it crashes the program! There's no bugs, it just says "Dark Basic Programming Tool has encountered a problem and needs to close. We're sorry for the inconvenience.". I checked everything; I'm deleting everything that exists, and I know that it all works. I've attached an .EXE to this post for others to test out. Maybe it's just my computer giving me a problem?
Here's the code, I know it works fine and isn't the problem (I think).
`============================================================
`Jewels Galore official source code, started May 20th,2009
`============================================================
Set Display Mode 1024,768,32 : `Default screen size for game
Hide Mouse : Backdrop On : Color Backdrop RGB(0,128,245)
Set Ambient Light 65 : Color Ambient Light RGB(255,255,255)
Sync On : Sync Rate 60
`--------------------------------------
`The Main Menu will go here later
`--------------------------------------
`Level 1
W1L1:
Cls
Autocam Off
`Declare jewel, score lives and coins variables
jewels=0 : score=0 : coins=0 : lives=3
`Declare check point and power-up variables
cpflag=0 : SupJump=0
`Create and texture player object using variable
Load Object "Media\sky1.x",900 : Scale object 900,2550,2550,2550 : Ghost object on 900 : XRotate Object 900,90 : Position object 900,0,0,0
Set Object Collision On 900 : Make Object Collision Box 900,.3,.3,.3,-.3,-.3,-.3,0
Load Image "Media\MarbleBlue.bmp",1
Make Object Sphere 1, .7 : Texture Object 1,1 : Position object 1,-10,15,0
Set Object Collision On 1 : Make Object Collision Box 1,-.3,-.3,-.3,.3,.3,.3,0
`Create and texture platforms
Load Object "Media\5block.x",2 : Position object 2,0,0,0 : Scale object 2,250,250,250 : Zrotate object 2,180
Set object 2,1,1,1 : XRotate Object 2, 90 : Set object collision on 2
Make object collision box 2,-12.5,-2.5,-2.5,12.5,2.5,2.5,0
Make Object Plain 100,25,5 : Xrotate object 100,90 : Position Object 100,0,2.6,0 : Hide Object 100
Load Object "Media\individual_block.x",3 : Position Object 3,15,5,0 : Scale object 3,250,250,250 : XRotate Object 3,180
Make Object Collision Box 3,-2.5,-2.5,-2.5,2.5,2.5,2.5,0
Make Object Plain 101,5,5 : Xrotate object 101,90 : Position Object 101,15,7.6,0 : Hide Object 101
`Load signpost
Load Object "Media\signpost.x", 4 : Position Object 4,17,8,-2 : ZRotate Object 4,90 : YRotate Object 4,112
Set Object Collision On 4 : Make Object Collision Box 4,-.3,-2,-.3,.3,2,.3,0
Make Object Plain 7,1,1 : Position Object 7, 16.5,8,-1.9 : YRotate Object 7,112 : Hide Object 7
`Load more platforms
Load Object "Media\5block.x",5 : Position Object 5,25,5,0 : Scale Object 5,250,250,250 : XRotate Object 5,90 :Set object collision on 5
Make object collision box 5,-2.5,-2.5,-12.5,2.5,2.5,12.5,0 : ZRotate object 5,90
Make Object Plain 102,5,25 : Xrotate object 102,90 : Position Object 102,25,7.6,0 : Hide Object 102
Load Object "Media\5block.x",6 : Position Object 6,40,10,0 : Scale Object 6,250,250,250 : XRotate Object 6,90
Set object collision on 6
Make object collision box 6,-12.5,-2.5,-2.5,12.5,2.5,2.5,0
Make Object Plain 103,25,5 : Xrotate object 103,90 : Position Object 103,40,12.6,0 : Hide Object 103
Load Object "Media\5block.x",8 : Position Object 8,55,10,10 : Scale Object 8,250,250,250 : XRotate Object 8,90
Make object collision box 8,-2.5,-2.5,-12.5,2.5,2.5,12.5,0 : ZRotate Object 8,90
Make Object Plain 104,5,25 : Xrotate object 104,90 : Position Object 104,55,12.6,10 : Hide Object 104
Load Object "Media\5block.x",9 : Position Object 9,70,15,20 : Scale Object 9,250,250,250 : XRotate Object 9,90
Make object collision box 9,-12.5,-2.5,-2.5,12.5,2.5,2.5,0
Make Object Plain 105,25,5 : Xrotate object 105,90 : Position Object 105,70,17.6,20 : Hide Object 105
Load Object "Media\individual_block.x",10 : Position Object 10,75,20,25 : Scale Object 10,250,250,250 : XRotate Object 10,180
Make object collision box 10,-2.5,-2.5,-2.5,2.5,2.5,2.5,0
Make Object Plain 106,5,5 : Xrotate object 106,90 : Position Object 106,75,22.6,25 : Hide Object 106
`Load jewels (number 200-224)
Load Object "Media\jewel.x",200 : Position Object 200, -5,3.5,0 : XRotate Object 200,90 : Scale Object 200,50,50,50
Load Object "Media\jewel.x",201 : Position Object 201,0,3.5,0 : XRotate Object 201,90 : Scale Object 201,50,50,50
Load Object "Media\jewel.x",202 : Position Object 202,5,3.5,0 : XRotate Object 202,90 : Scale Object 202,50,50,50
Load Object "Media\jewel.x",203 : Position Object 203,10,3.5,0 : XRotate Object 203,90 : Scale Object 203,50,50,50
Load Object "Media\jewel.x",204 : Position Object 204,15,8.5,0 : XRotate Object 204,90 : Scale Object 204,50,50,50
Load Object "Media\jewel.x",205 : Position Object 205,25,8.5,0 : XRotate Object 205,90 : Scale Object 205,50,50,50
Load Object "Media\jewel.x",206 : Position Object 206,25,8.5,5 : XRotate Object 206,90 : Scale Object 206,50,50,50
Load Object "Media\jewel.x",207 : Position Object 207,25,8.5,10 : XRotate Object 207,90 : Scale Object 207,50,50,50
Load Object "Media\jewel.x",208 : Position Object 208,25,8.5,-5 : XRotate Object 208,90 : Scale Object 208,50,50,50
Load Object "Media\jewel.x",209 : Position Object 209,25,8.5,-10 : XRotate Object 209,90 : Scale Object 209,50,50,50
Load Object "Media\jewel.x",210 : Position Object 210,30,13.5,0 : XRotate Object 210,90 : Scale Object 210,50,50,50
Load Object "Media\jewel.x",211 : Position Object 211,35,13.5,0 : XRotate Object 211,90 : Scale Object 211,50,50,50
Load Object "Media\jewel.x",212 : Position Object 212,40,13.5,0 : XRotate Object 212,90 : Scale Object 212,50,50,50
Load Object "Media\jewel.x",213 : Position Object 213,45,13.5,0 : Xrotate Object 213,90 : Scale Object 213,50,50,50
Load Object "Media\jewel.x",214 : Position Object 214,50,13.5,0 : XRotate Object 214,90 : Scale Object 214,50,50,50
Load Object "Media\jewel.x",215 : Position Object 215,55,13.5,0 : XRotate Object 215,90 : Scale Object 215,50,50,50
Load Object "Media\jewel.x",216 : Position Object 216,55,13.5,5 : XRotate Object 216,90 : Scale Object 216,50,50,50
Load Object "Media\jewel.x",217 : Position Object 217,55,13.5,10 : XRotate Object 217,90 : Scale Object 217,50,50,50
Load Object "Media\jewel.x",218 : Position Object 218,55,13.5,15 : XRotate Object 218,90 : SCale Object 218,50,50,50
Load Object "Media\jewel.x",219 : Position Object 219,55,13.5,20 : XRotate Object 219,90 : Scale Object 219,50,50,50
For nocollision=200 to 219
Set Object Collision Off nocollision
Make Object Collision Box nocollision,.5,.5,.5,-.5,-.5,-.5,0
Next nocollision
`-------------------------------------------------
`T h e M a i n P r o g r a m L o o p
`-------------------------------------------------
Do
`Print fps and lives to the screen
Text 0,0,"FPS: " +Str$(Screen fps() )
Text 0,12,"Lives: "+Str$(lives)
`Rotate Jewels in for..next loop
For rotateJewel = 200 To 219
ZRotate Object rotateJewel,Wrapvalue(Object Angle Z(rotateJewel)-3)
Next rotateJewel
`Read signposts
If Object Collision(1,7) And ReturnKey()=1 Then GoSub read_signpost1
`Pause
If InKey$()="p" Then GoSub Pause
`Death Routine
If Object Position Y(1)=<-20 Then Sleep 500 : Position Object 1,-10,15,0 : lives=lives-1 : If lives=<0 Then GoSub Lose
`Call input function
CheckInput()
`Jumping
If ControlKey()=1
Success=0 :`This will tell us if we're colliding with the invisible plains or not
For plat = 100 To 106
If Object Collision(1,plat)=1 Then Success=1
Next plat
If Success=1 :`If we're touching a plain
If SupJump=1 Then playergrav#=0.45 : Else playergrav#=0.35
EndIf
Endif
`Get current object position
posx#=object position x(1) : posy#=object position y(1) : posz#=object position z(1)
`Set up gravity
playergrav#=playergrav#-0.01
posy#=posy#+playergrav#
`Sliding collision
position object 1,posx#,posy#,posz#
if object collision(1,0)>0
dec posx#,get object collision x() : dec posy#,get object collision y() : dec posz#,get object collision z()
playergrav#=-0.0
endif
`set size for controlled object
s#=object size y(1)/2.0
`update with new object position
position object 1,posx#,posy#,posz#
`camera
angle#=object angle y(1)
camdist#=10.5 : camhigh#=posy#+2.5 : camfade#=12.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
xrotate camera 10
`end loop
Sync
Loop
`++++++++++++++++++++++++++++++++++++
`Winning And Losing Routines
`++++++++++++++++++++++++++++++++++++
`---------------
`Losing Routine
`---------------
Lose:
Cls
`Delete any loaded textures
Delete Image 1
`Delete skybox
Delete Object 900
`Delete player and platforms
For del_obj= 1 to 10
Delete Object del_obj
Next del_obj
`Delete jumping plains
For del_pln= 100 to 106
Delete Object del_pln
Next del_pln
`Delete jewels
For delJel=200 To 219
Delete Object delJel
Next delJel
GoSub W1L1:
`************************************
`S u b r o u t i n e s
`************************************
`Pause subroutine
Pause:
Do
Text 0,0,"FPS: " +Str$(Screen fps() )
Text 0,12,"Lives: "+Str$(lives)
Center Text 500,300,"PAUSE"
Center Text 500,312,"Press Space To Resume Play"
If SpaceKey()=1 Then Exit
Sync
Loop
Return
`Read the first signpost
read_signpost1:
Do
Text 0,0,"FPS: " +Str$(Screen fps() )
Text 0,12,"Lives: "+Str$(lives)
`Draw a box to contain the text in
Ink RGB(76,76,76),0 : `Color the box gray
x1=285 : y1=95 : x2=715 : y2=195
Box x1,y1,x2,y2
`Render the text
Ink RGB(0,0,0),0 : `Creates a shadow
Center Text 501,101,"Hello there! Let Bill the Signpost guide you through"
Center Text 501,116,"a few things before you continue on your way!"
Center Text 501,131,"You must collect all 25 Jewels in each level. Some are"
Center Text 501,146,"easy to reach, others are way out there. When"
Center Text 501,161,"there's something new introduced in a level, one of my friends"
Center Text 501,176,"will be there. Now be off! Collect those Jewels."
Ink RGB(255,255,255),0 : `Renders text in white
Center Text 500,100,"Hello there! Let Bill the Signpost guide you through"
Center Text 500,115,"a few things before you continue on your way!"
Center Text 500,130,"You must collect all 25 Jewels in each level. Some are"
Center Text 500,145,"easy to reach, others are way out there. When"
Center Text 500,160,"there's something new introduced in a level, one of my friends"
Center Text 500,175,"will be there. Now be off! Collect those Jewels."
If SpaceKey()=1 Then Exit
Sync
Loop
Return : `Return to the main program
`+++++++++++++++++++++++++++++
`F U N C T I O N S
`+++++++++++++++++++++++++++++
Function CheckInput()
If UpKey()=1 Then Move Object 1,0.23 : Scroll Object Texture 1,0.00,0.02
If DownKey()=1 Then Move Object 1,-0.23 : Scroll Object Texture 1, 0.00,-0.02
If LeftKey()=1 Then yrotate object 1,wrapvalue(object angle y(1)-1.5)
If RightKey()=1 Then yrotate object 1,wrapvalue(object angle y(1)+1.5)
EndFunction
Has anyone ever had this problem before?

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87