What`s Wrong With This Damn Code Segment?


Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
40
Location
Dteuschland ;)
Code:
LOOP

 scrollx = 370; 
 while(scrollx > -40)   //this while-loop makes the scores scroll across the screen from right to left.
  delete_text (text1);
  scrollx -= 2;
  write_int(0,scrollx,117,0, &pointscounter);
  frame; 
 end;

 if(key(_enter))gameover(0,0);return;end;  //end game by pressing start
 if(lifecounter<=0)gameover(0,0);return;end;  //end game by losing all health

 FRAME;
END;

If the game ends normally by loosing all health, the points scroll until they are offscreen, and the game exits fine into the gameover/highscore screen.
But if I end the game by pressing START, the score keeps scrolling like an infinite loop and you have to restart.

Why? Why is the second "if..." working and the first not?

EDIT: spelling mistake, so there will be no exploding super nova (do super novas explode? I hope so...)
 
I don't know why... but you can try this:

if(key(_enter)) lifecounter=0; end; //end game by pressing start

Cheap, but may works.
 
Nice idea, but I already tried that, it doesn`t work. It doesn`t even set the lifecounter to zero, I notice that because it`s displayed on screen. Very strange.

I can enter every command I like behin the if(key(_enter)) but it doesn`t call that command. I even deleted all other if(key(_enter)) from my source code, just to try out, but that doesn`t change anything... it doesn`t have to be _enter, I tried _space, which doesn`t work either...
 
You're only checking for a button press after the while loop (ie, when the score is off the screen), so pressing start will probably only have an effect for a split second. Try holding down start and see what happens. Putting the if's into the while loop should call gameover when you press start, but if you want to wait for the score to disappear then remove your _enter if statement, replace it with Hokutoy's version, then move just that if statement to within the loop (press start within the loop and lives are set to 0, after the score has gone gameover will be called).
 
Many thanks Woogal! I never would have thought of that.

I don`t really want the score to scroll across after a gameover, I just thought it was a nice side effect (though I didn`t know what caused it ;) )

After putting that into the while loop, it works!
 
Yes, now that you tell me, Mr. Dictionary. :D

Actually, it doesn`t matter cause I just wrote those comments just for this thread, so... it doesn`t matter!

Oh, and you know, you forgot to set a "," after wrong, don`t you?
 
Quiest posted on Mar 4 2005 at 03:21 PM said:
Yes, now that you tell me, Mr. Dictionary. :D

Actually, it doesn`t matter cause I just wrote those comments just for this thread, so... it doesn`t matter!

Oh, and you know, you forgot to set a "," after wrong, don`t you?


EDIT: BTW, can anyone tell me what`s the usual (proper) way to set backgrounds? Since the way I used for the game process background only worked once (I noticed after making main menu and config menu backgrounds), I thought, I might be doing something wrong...

oh :rolleyes:
look, i dont do grammer.
 
Last edited by a moderator:
Nova, are you trolling, or are you just exceptionally stupid? Out of all the people to point out someone's spelling mistakes, out of all the thousands of posts that have spelling mistakes in them, why did you decide to point out that post?! It boggles the mind.
 
Back
Top