Posted: 24th Jun 2007 21:19
When I compile my program (i.e. press F5), the game compiles Ok, but then the .exe won't run. Basically I can't run my program

It's a weird problem because there doesn't appear to be anything wrong with my code and although I searched and found some relevant posts they couldn't help.

My question is, is it the code or a random bug?

(Ineffecent) code:

+ Code Snippet
sync on : sync rate 60 : hide mouse : autocam off
set text font "Arial" : set text size 12

gosub mm

gosub start

level=1
turn=1
score=1
objcolour$="White"

position camera 0,100,-10
point camera 0,0,0

redo:
score2=score
if object exist(1)=0
   make object sphere 1,5
endif
dim active(600)
combination(course,level)

if course=1 then makelevel1()
if course=2 then makelevel2()
if course=3 then makelevel3()
if course=4 then makelevel4()
if course=5 then makelevel5()
if course=6 then makelevel6()
if course=7 then makelevel7()

redo3:
position object 1,-70,0,0
yrotate object 1,90

make object sphere 2,2
color object 1,rgb(255,255,255)

stage=0
gosub desc
time=timer()
movement=1
tii3=timer()

do

    if level=9
      delete object 1
      delete object 2
      level=1 : course=1
      undim active()
      for f=3 to 200
         if object exist(f)=1
            delete object f
            sc_removeobject f
         endif
      next f
      gosub results
      gosub start
      gosub redo
   endif

    OX# = Object position x(1)
    OY# = Object position y(1)
    OZ# = Object position z(1)

    if stage=0 and turn=1
      ink rgb(255,0,0),0
      center text (screen width()/2),(screen height()/2)-20,"Level "+str$(level)
      center text screen width()/2,(screen height()/2),"Prepare to play..."
      center text screen width()/2,(screen height()/2)+20,desc$
      ink rgb(255,255,255),0
    endif
    if turn=2 then stage=1 : turn=0
    if (timer()-time)/1000>2 and stage=0 then stage=1
    if spacekey()=1 and stage=1 then delete object 2 : time=timer() : stage=2
    if stage=2 then move object 1,1
`----------------------------------------------------------------------------------------------
      for a=3 to 600
         for v=3 to 6
            if object exist(a)=1 and movement=1
               if active(a)=v then yrotate object a,object angle y(a)+(v-2) : sc_updateobject a
            endif
         next v
         if object exist(a)=1 and movement=1
            if active(a)=14 then yrotate object a,object angle y(a)+1 : sc_updateobject a
         endif
         if object exist(a)=1
            if active(a)=7 and object collision(1,a) then yrotate object 1,90
         endif
         if object exist(a)=1
            if active(a)=9
               if object collision(1,a) and object visible(a)=1 then inc score : gosub redo2
            endif
         endif
         if object exist(a)=1
            if active(a)=8 and object collision(1,a) then color object 1,rgb(0,75,255) : objcolour$="blue" : tii3=timer()
            if active(a)=12 and object collision(1,a) then color object 1,rgb(255,0,0) : objcolour$="red" : tii3=timer()
         endif
         if (timer()-tii3)>750 then objcolour$="white" : color object 1,rgb(255,255,255)
         if object exist(a)=1
            if active(a)=10 and objcolour$="blue" then ghost object on a : sc_setupobject a,2,0
            if active(a)=10 and objcolour$="white" then ghost object on a : sc_setupobject a,1,0
            if active(a)=10 and objcolour$="red" then ghost object on a : sc_setupobject a,1,0
            if active(a)=11 and objcolour$="white" then ghost object on a : sc_setupobject a,1,0
            if active(a)=11 and objcolour$="blue" then ghost object on a : sc_setupobject a,1,0
            if active(a)=11 and objcolour$="red" then ghost object on a : sc_setupobject a,2,0
            if active(a)=13 and objcolour$="white" then ghost object on a : sc_setupobject a,2,0
            if active(a)=13 and objcolour$="blue" then ghost object on a : sc_setupobject a,1,0
            if active(a)=13 and objcolour$="red" then ghost object on a : sc_setupobject a,1,0
            if active(a)=14 and objcolour$="white" then ghost object on a : sc_setupobject a,2,0
            if active(a)=14 and objcolour$="blue" then ghost object on a : sc_setupobject a,1,0
            if active(a)=14 and objcolour$="red" then ghost object on a : sc_setupobject a,1,0
         endif
      next a
`---------------------------------------------------------------------------------------------

    text 20,20,"Ball no."+str$(Score)

    if stage=5
      ink rgb(255,0,0),0
      center text screen width()/2,screen height()/2,"Ok then, maybe we should skip this level..."
      ink rgb(255,255,255),0
    endif

    if score2+8=score
      score2=score
      time=timer()
      stage=5
    endif

    if stage=5 and (timer()-time)/1000>2 then inc level : gosub cont

    position object 1,object position x(1),0,object position z(1)

    X# = Object position x(1)
    Y# = Object position y(1)
    Z# = Object position z(1)

    BouncingCollision(OX#,OY#,OZ#,X#,Y#,Z#,2.5,1,1)

    gosub Locatecursor

    gosub objectives

    sync

loop

function BouncingCollision(X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,Dyn,Group)

    Collisionofball = sc_SphereSlideGroup(Group,X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,0)

    if Collisionofball>0

          NewX# = sc_getStaticCollisionX()
          NewY# = sc_getStaticCollisionY()
          NewZ# = sc_getStaticCollisionZ()

          NormX# = sc_getCollisionBounceX()
          NormY# = sc_getCollisionBounceY()
          NormZ# = sc_getCollisionBounceZ()

          position object Dyn,NewX#,NewY#,NewZ#
          point object Dyn,NewX#+NormX#,NewY#+NormY#,NewZ#+NormZ#

    endif

endfunction

DELETE MEMBLOCK 1

locatecursor:
if stage=1
   pick screen mousex(),mousey(),100
   z#=get pick vector z()
   x#=get pick vector x()
   point object 1,x#,0,z#
   position object 2,x#,0,z#
endif
return

objectives:
if object position x(1)<-80 then inc score : gosub redo2
if object position z(1)<-55 then inc score : gosub redo2
if object position z(1)>60 then inc score : gosub redo2
if (timer()-time)/1000>12 and stage=2 then color object 1,rgb(255,0,0) : objcolour$="red" : tii3=timer()
if (timer()-time)/1000=15 and stage=2 then color object 1,rgb(255,255,255) : objcolour$="white" : gosub redo2
if mouseclick()=2 then inc level : gosub cont
if object position x(1)>80 and object position z(1)<40 and object position z(1)>-40 then inc level : gosub cont
return

desc:
if level=1 and course=1 then desc$="'Nice and easy'"
if level=2 and course=1 then desc$="'Big wall!'"
if level=3 and course=1 then desc$="'Bumpy road'"
if level=4 and course=1 then desc$="'Tough Angle'"
if level=5 and course=1 then desc$="'Rebound!'"
if level=6 and course=1 then desc$="'Tunnel trail'"
if level=7 and course=1 then desc$="'Quadrant trial'"
if level=8 and course=1 then desc$="'DELETE THIS LEVEL'"
if level=1 and course=2 then desc$="'Diamond Junction'"
if level=2 and course=2 then desc$="'Twisty Turns'"
if level=3 and course=2 then desc$="'Spiral!'"
if level=4 and course=2 then desc$="'Symmetrical mix'"
if level=5 and course=2 then desc$="'Think outside the box ;)'"
if level=6 and course=2 then desc$="'Collision mania'"
if level=7 and course=2 then desc$="'Another box!'"
if level=8 and course=2 then desc$="'Round the corner'"
if level=1 and course=3 then desc$="'Ha, now you're in trouble'"
if level=2 and course=3 then desc$="'Deja vu'"
if level=3 and course=3 then desc$="'Speed crisis'"
if level=4 and course=3 then desc$="'Timing is crucial'"
if level=5 and course=3 then desc$="'Towers'"
if level=6 and course=3 then desc$="'Vaciation from spinning thingys'"
if level=7 and course=3 then desc$="'DELETE THIS LEVEL'"
if level=8 and course=3 then desc$="'Rebound'"
if level=1 and course=4 then desc$="'The arrow route'"
if level=2 and course=4 then desc$="'Rebound meets tunnel trail'"
if level=3 and course=4 then desc$="'Mystery Blocks'"
if level=4 and course=4 then desc$="'4xblocks'"
if level=5 and course=4 then desc$="'A tight fit'"
if level=6 and course=4 then desc$="'Enter the red hot things'"
if level=7 and course=4 then desc$="Guest level: Made by 'Sharkfin'"
if level=8 and course=4 then desc$="'More spikes!'"
return

cont:
for b=3 to 600
    if object exist(b)=1
       delete object b
       sc_removeobject b
    endif
next b
delete object 2
turn=1
undim active()
sleep 200
gosub redo

redo2:
turn=2
gosub redo3

start:
backdrop on
course=1
tii=timer()
color backdrop rgb(0,0,0)
do
if course=1 then ink rgb(255,0,0),0 : center text screen width()/2,40,"The beginners course" : else ink rgb(255,255,255),0 : center text screen width()/2,40,"The beginners course"
if course=2 then ink rgb(255,0,0),0 : center text screen width()/2,60,"More of a challenge ;)" : else ink rgb(255,255,255),0 : center text screen width()/2,60,"More of a challenge ;)"
if course=3 then ink rgb(255,0,0),0 : center text screen width()/2,80,"Spiral zone" : else ink rgb(255,255,255),0 : center text screen width()/2,80,"Spiral zone"
if course=4 then ink rgb(255,0,0),0 : center text screen width()/2,100,"Experienced route" : else ink rgb(255,255,255),0 : center text screen width()/2,100,"Experienced route"
if course=5 then ink rgb(255,0,0),0 : center text screen width()/2,120,"Fire & water" : else ink rgb(255,255,255),0 : center text screen width()/2,120,"Fire & water"
if course=6 then ink rgb(255,0,0),0 : center text screen width()/2,140,"The even more experienced route" : else ink rgb(255,255,255),0 : center text screen width()/2,140,"The even more experienced route"
if course=7 then ink rgb(255,0,0),0 : center text screen width()/2,140,"Geometric dimension" : else ink rgb(255,255,255),0 : center text screen width()/2,140,"Geometric dimension"
if course>7 then ink rgb(255,0,0),0 : center text screen width()/2,430,"Return" : else ink rgb(255,255,255),0 : center text screen width()/2,430,"Return"
if downkey()=1 and course<8 and (timer()-tii)>200 then tii=timer() : inc course
if upkey()=1 and course>1 and (timer()-tii)>200 then tii=timer() : dec course
if returnkey()=1 and course<8 then sleep 200 : return
if returnkey()=1 and course>7 then sleep 200 : gosub mm
sync
loop
return

mm:
backdrop on
course=1
tiit=timer()
color backdrop rgb(0,0,0)
load image "logo.jpg",1
do
paste image 1,100,10
if course=1 then ink rgb(255,0,0),0 : center text screen width()/2,(screen height()/2)-40,"Play Speedball" : else ink rgb(255,255,255),0 : center text screen width()/2,(screen height()/2)-40,"Play Speedball"
if course=2 then ink rgb(255,0,0),0 : center text screen width()/2,(screen height()/2),"Options [Currently Unavailable]" : else ink rgb(255,255,255),0 : center text screen width()/2,(screen height()/2),"Options"
if course=3 then ink rgb(255,0,0),0 : center text screen width()/2,(screen height()/2)+40,"Quit" : else ink rgb(255,255,255),0 : center text screen width()/2,(screen height()/2)+40,"Quit"
if downkey()=1 and course<3 and (timer()-tii)>200 then tii=timer() : inc course
if upkey()=1 and course>1 and (timer()-tii)>200 then tii=timer() : dec course
if returnkey()=1
   if course=1 then sleep 200 : cls : delete image 1 : return
   if course=3 then end
endif
sync
loop
return

results:
tii=timer()
do
if score>0 and score<9 then ink rgb(0,255,0),0 : center text screen width()/2,(screen height()/2)+20,"Amazing score! Congratulations :)"
if score>8 and score<17 then ink rgb(50,200,0),0 : center text screen width()/2,(screen height()/2)+20,"Well done, that's a good - maybe great score :)"
if score>16 and score<31 then ink rgb(20,150,0),0 : center text screen width()/2,(screen height()/2)+20,"That's pretty good, just keep working on your technique ;)"
if score>30 and score<47 then ink rgb(255,200,0),0 : center text screen width()/2,(screen height()/2)+20,"That's ok, but there's room for improvement"
if score>46 and score<65 then ink rgb(255,0,0),0 : center text screen width()/2,(screen height()/2)+20,"Unlucky, you need to practice more"
center text screen width()/2,(screen height()/2)-20,"You used "+str$(score)+" balls"
if (timer()-tii)/1000>2 then cls : score=1 : return
sync
loop

function combination(c,l)
if c=1 and l=1 then restore 1
if c=1 and l=2 then restore 2
if c=1 and l=3 then restore 3
if c=1 and l=4 then restore 4
if c=1 and l=5 then restore 5
if c=1 and l=6 then restore 6
if c=1 and l=7 then restore 7
if c=1 and l=8 then restore 8
if c=2 and l=1 then restore 9
if c=2 and l=2 then restore 10
if c=2 and l=3 then restore 11
if c=2 and l=4 then restore 12
if c=2 and l=5 then restore 13
if c=2 and l=6 then restore 14
if c=2 and l=7 then restore 15
if c=2 and l=8 then restore 16
if c=3 and l=1 then restore 17
if c=3 and l=2 then restore 18
if c=3 and l=3 then restore 19
if c=3 and l=4 then restore 20
if c=3 and l=5 then restore 21
if c=3 and l=6 then restore 22
if c=3 and l=7 then restore 23
if c=3 and l=8 then restore 24
if c=4 and l=1 then restore 25
if c=4 and l=2 then restore 26
if c=4 and l=3 then restore 27
if c=4 and l=4 then restore 28
if c=4 and l=5 then restore 29
if c=4 and l=6 then restore 30
if c=4 and l=7 then restore 31
if c=4 and l=8 then restore 32
if c=5 and l=1 then restore 33
if c=5 and l=2 then restore 34
if c=5 and l=3 then restore 35
if c=5 and l=4 then restore 36
if c=5 and l=5 then restore 37
if c=5 and l=6 then restore 38
if c=5 and l=7 then restore 39
if c=5 and l=8 then restore 40
if c=6 and l=1 then restore 41
if c=6 and l=2 then restore 42
if c=6 and l=3 then restore 43
if c=6 and l=4 then restore 44
if c=6 and l=5 then restore 45
if c=6 and l=6 then restore 46
if c=6 and l=7 then restore 47
if c=6 and l=8 then restore 48
if c=7 and l=1 then restore 49
if c=7 and l=2 then restore 50
if c=7 and l=3 then restore 51
if c=7 and l=4 then restore 52
if c=7 and l=5 then restore 53
if c=7 and l=6 then restore 54
if c=7 and l=7 then restore 55
if c=7 and l=8 then restore 56
endfunction


Ps. I know that the code is very long - especially that last bit. So I understand if I only get few replies (if any).
Posted: 24th Jun 2007 22:50
Try creating a simple test project, and seeing if that will run:

+ Code Snippet
print "Hello, World!"
wait key : end


Does the compiler give any error messages? What are your system specs?

G2L
Posted: 24th Jun 2007 23:42
the simplest thing to do would be to re-install darkbasic pro
and see what happens!
Posted: 24th Jun 2007 23:54
Retrace your steps, what was the last bit of code you added before it stopped working, delete and see if it works again, then all you have to do is find the problem in the added code.
Posted: 25th Jun 2007 18:55
Try creating a simple test project, and seeing if that will run


The hello world code works, as does everything else other than this, so it must be my code

I retraced my steps and the following code appears to be the source of the problem - the inefficent bit

+ Code Snippet
function combination(c,l)
if c=1 and l=1 then restore 1
if c=1 and l=2 then restore 2
if c=1 and l=3 then restore 3
if c=1 and l=4 then restore 4
if c=1 and l=5 then restore 5
if c=1 and l=6 then restore 6
if c=1 and l=7 then restore 7
if c=1 and l=8 then restore 8
if c=2 and l=1 then restore 9
if c=2 and l=2 then restore 10
if c=2 and l=3 then restore 11
if c=2 and l=4 then restore 12
if c=2 and l=5 then restore 13
if c=2 and l=6 then restore 14
if c=2 and l=7 then restore 15
if c=2 and l=8 then restore 16
if c=3 and l=1 then restore 17
if c=3 and l=2 then restore 18
if c=3 and l=3 then restore 19
if c=3 and l=4 then restore 20
if c=3 and l=5 then restore 21
if c=3 and l=6 then restore 22
if c=3 and l=7 then restore 23
if c=3 and l=8 then restore 24
if c=4 and l=1 then restore 25
if c=4 and l=2 then restore 26
if c=4 and l=3 then restore 27
if c=4 and l=4 then restore 28
if c=4 and l=5 then restore 29
if c=4 and l=6 then restore 30
if c=4 and l=7 then restore 31
if c=4 and l=8 then restore 32
if c=5 and l=1 then restore 33
if c=5 and l=2 then restore 34
if c=5 and l=3 then restore 35
if c=5 and l=4 then restore 36
if c=5 and l=5 then restore 37
if c=5 and l=6 then restore 38
if c=5 and l=7 then restore 39
if c=5 and l=8 then restore 40
if c=6 and l=1 then restore 41
if c=6 and l=2 then restore 42
if c=6 and l=3 then restore 43
if c=6 and l=4 then restore 44
if c=6 and l=5 then restore 45
if c=6 and l=6 then restore 46
if c=6 and l=7 then restore 47
if c=6 and l=8 then restore 48
if c=7 and l=1 then restore 49
if c=7 and l=2 then restore 50
if c=7 and l=3 then restore 51
if c=7 and l=4 then restore 52
if c=7 and l=5 then restore 53
if c=7 and l=6 then restore 54
if c=7 and l=7 then restore 55
if c=7 and l=8 then restore 56
endfunction


I'll use reinstalling DBP as a last resort because I don't want to mess around with Dark Basic too much, also I think it's the code that is the problem with compiling
Posted: 25th Jun 2007 19:21
Your restore statements look wrong to me. You're using numbers, but you should be using labels. According to the help files on the Restore command...

The label can be made up from any combination of alphabetic characters


Not alphanumeric characters. Try changing the labels to alphabetic ones and see if that helps.

I know you know already, but that function looks like a big turd
Posted: 25th Jun 2007 22:24
our restore statements look wrong to me. You're using numbers, but you should be using labels. According to the help files on the Restore command...

Quote: "The label can be made up from any combination of alphabetic characters"


I tried changing the labels into letters but it made no difference. Numbers seem to work fine for me when I use them with the restore command and they worked before this problem occured so it must be something else about the function.

but that function looks like a big turd


Well that's one way of describing it
Posted: 25th Jun 2007 22:36
Where are the makeleveln() functions? I can't compile it; is it a separate source, or perhaps a plug-in?

EDIT: never mind, you are using sparky's, I don't have that.
Posted: 25th Jun 2007 23:13
It's a function from another source file, although I am sure that the problem isn't from there, after all I haven't edited those source files at all for ages.
Posted: 30th Jun 2007 19:59
Half relevant question:

I partially solved the problem, but well... there is still a problem. When I load my levels from data commands present in my code, the compiler won't run if there are any more than 32,400 data values in the project. That may seem a lot but every level contains 30x20 values and my game contains a lot of levels - the game won't run after level 54 which I can tell you - is annoying.

Is there a limit to the amount of data I can use or is there a better way of loading the level data? I tried putting the data into a saved array but I failed miserably! :p
Posted: 1st Jul 2007 4:07
Yeah you can store the data in a file in any number of ways. Check out the read and write commands it's pretty straightforward.