Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / How to return to the point where you paused

Author
Message
Yodaman Jer
User Banned
Posted: 22nd Feb 2008 18:05
I"m having trouble with pausing. When the player pauses it's supposed to go to this pause menu. It does. But when you want to go back, it starts the level over again. I used gosub to get there and gosub to get back, which probably is going to be the culprit(or just part of the culprit), but I don't know how to get back to point when the player pauses.
Here's the code:


Can anyone tell me of a way HOW to get back? That doesn't involve gosub?
I'm thinking it will have to be stored in an array or a variable or something...

Yodaman Jer



Thanks to BigAdd for the incredibly awesome sig!
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Feb 2008 18:26 Edited at: 22nd Feb 2008 18:32
Gosub and Return are pair! So if you gosub a sub-routine, then in order to return to the point of the calling gosub statement, we need to call RETURN. This will jump us back like nothing ever happened.


So this,




Would be,




Although, i'd structure it a little differently, as at the moment when the users presses the SPACE KEY they will most likely jump from the game to the pause screen and back again. Since the SPACEKEY() will probably still equal one (the person still their finger on the key) when computer is running the Pause Loop and then exit back to the game.

It would occur because the computer is running the code faster than the person can lift their finger from the Space bar. An easy way around this is would be to let the pause loop start the DO/LOOp, until the space key was released (Spacekey()=0). Which would work, but it's not the best solution.

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Feb 2008 18:34
Try storing the player positions:



When you return out of the subroutine, like Kevin Picone explained, you restore the positions of the player:



I hope this helps

TheComet

Oooooops!!! I accidentally formated drive c.
Yodaman Jer
User Banned
Posted: 22nd Feb 2008 19:17 Edited at: 22nd Feb 2008 19:18
Thanks guys, it worked perfectly!
Thanks!

Yodaman Jer


Thanks BigAdd!!

Login to post a reply

Server time is: 2025-06-04 01:55:03
Your offset time is: 2025-06-04 01:55:03