ID:170068
 
How in the world would you make a pause function?

Almost every game has it- whether it be Deus Ex, Fifa, Zelda- but how does it *work*?
(obviously it's not very applicable in multiplayer games, but since BYOND can easily be single player...)

Is there an if() in *every* function in the game checking a pause variable?

That seems inefficient to me. Is there an easier way?
Hmm, I've thought of it before, and it does seem complicated. The way I was thinking of doing it was using the for() thing for every atom in the world, make them stop moving, Also, try making a variable for atom, call it "frozen" <_< Then 'if' the hell out of procedures that don't require movement to work, then use that for() thing above to turn it on, :-/ That probably wouldn't do much, but meh.

-- Super Squirrel
((Mmm, lemon snow!))
Elation wrote:
Is there an if() in *every* function in the game checking a pause variable?

Of course not!

If the player can't do anything while the game is paused, then the only actions that could possibly be occuring during a pause are infinite loops. Therefore, you merely need to place while(!game_pasued) statements inside those loops, and when the game is unpaused, you need to re-initialize the loops that were running before the pause.
Typically those games are programmed with a game loop. If you don't know what a game loop is, you obviously don't know anything about the real world of video game programming...

Games that are programmed in real programming languages tend to have a loop that handles everything, and exits when the player decides to quit the game. basically, before any processing is done for the next portion of the loop, most of them have an if function that checks to see if that aspect of the game is paused.

BYOND would be much harder to apply this to.
In response to Ter13
I see.

It just always confused me how you could press pause and stop a bullet in mid air- would that mean that it'd have to keep checking to keep moving?

Thanks for clearing it up, partially. :)

Sorry if I was asking a silly question.
In response to Elation
Yes and no.

Games are based in the main loop:

(THIS IS NOT DM, this is a C++ like syntax.)
public void main(string args[])
{
bool game_running = true;
bool game_paused = true;
while(game_running)
{
if(!game_paused)
{
//run all the events that run the game.
//first it should get all keypresses, and then it
//should perform all game activity, such as telling
//all the objects in the world to perform one action.
//when everything is done, it will just loop over.
}
else
{
//run the paused function.
//the paused function should just listen for
//keypresses to the pause button so it can unpause.
}
}
return void;
}


Do you get this at all? BYOND pretty much handles the game loop for you by default, so it'd be really hard to set this kind of a system up.
In response to Ter13
Indeed, I understand.

Thanks a lot, Ter: You the man! (or something)
In response to Ter13
Ter13 wrote:
Do you get this at all? BYOND pretty much handles the game loop for you by default, so it'd be really hard to set this kind of a system up.

It's not hard to set up that kind of system in BYOND. Darke Dungeon uses a global game loop. Most verb actions function outside the loop (say, get, etc.), but all movement, combat, and item use does.

Deadron's Event Loop library is a good starting point for this technique.