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.

Dark GDK / Pause Function

Author
Message
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 2nd Sep 2010 09:47
Does anyone know if there is a function designed to pause a game such as dbGamePause? =P Or would know a suggested way to do so? Im making a simple 2d block break game.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 2nd Sep 2010 12:41
Quote: "
dbWait : void dbWait ( int iWait )
dbSleep : void dbSleep ( int iSleep )
dbWaitKey : void dbWaitKey ( void )
dbWaitMouse : void dbWaitMouse ( void )
dbSuspendForKey : void dbSuspendForKey ( void )
dbSuspendForMouse : void dbSuspendForMouse ( void )
"


All of these functions will pause the game. I'm sure one of them will do for your project.

JTK
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 2nd Sep 2010 18:53
You could also do something like this to make a pause screen.



http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 4th Sep 2010 00:15
Thank you both for your responses. JTK, the functions dbWaitKey() and dbSuspendForKey() are great for pausing, but I can hit any key to make the game resume. Im not really sure how to get the process to work directly with one key. Otherwise, Cuddle; the code your pasted was quite helpful. I got the game to pause when I please, but now its causing collision issues. Instead of the ball bouncing off blocks and walls, it goes through the blocks and straight off the screen from its starting direction. Here is what I made:



I called the function pauseGame() within the gamePlay() where the game screen is in play. I figured just calling that function within the actual game function it would just be recognized whenever i felt to hit the key, but it is causing this issue.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 4th Sep 2010 00:47 Edited at: 4th Sep 2010 00:59
The first thing I can tell you is that code snippet I gave you is for your game loop in the "void DarkGDK()" function definition, it is not supposed to be it's own function.

You see, those if statement in that "while (LoopGDK())" Loop are supposed to tell the program what to do when the game is paused and when it is not.

All you need to do is just slightly modify your game loop to reflect this method.

Just put the paused game code in the "if (isPaused)" section, and the actual game code in the "else" section of that one if statement.

Here, let me illustrate an example of proper usage:


Where you place the dbCLS() and dbSync() code is up to you, like if you place it right, you can have that "Game Paused" message over a freeze frame of the game. Or like in the example above, it cuts to a blank screen.

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 7th Sep 2010 20:02
Right on. The way I have my game loop is through an enumeration. So my code is set to create different screens through a switch statement. So the pause function I made is actually placed within the LoopGDK(). With what you explain, I placed the code within the LoopGDK() and got the same results. I can get the game to pause. Im not entirely sure how to get it unpause without messing up the game code. It does the same thing I mentioned before; going out of the screen. Just so were on the same page, here is how my game code works.





This is the beginning part, and as you can see, I have seperate functions that will flip around from the switch statement appropriately through the game play. I just have this feeling that Im either approaching the else statement to continue the game after pause or the whole pause code isnt being properly placed within the project.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 7th Sep 2010 21:31
Could I not make it part of the enum/switch? If this key is pressed during gameplay, it will trigger the switch to the gamePause setup, and if pressed again, goes back to the gamePlay? Also. If I place the pause code within the LoopGDK, the game can be paused even before gettin to get the actual gamePlay.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Greg_C
14
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 8th Sep 2010 04:22
Well I haven't read this whole post but an easy way to do it with the case switch is to just make another switch case like so:



Then in your gamePlay() function just have a check to see if the player pressed the button to pause the game. then go to that state. Now if you have multiple states that can use the pause function then you can do some sort of GetLastState() and then just have the pause go back to the last state, but it seems like you just have one game state so should be pretty easy.

Hope this helps.
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 8th Sep 2010 18:48
Greg C....lol thats funny. Thats actually my name. Greg Clark =P... To tell ya the truth, after that last post I made, I did make it a part of my enum/ switch list. It still is doing the same thing. I created the gamePause() and placed its call within the gamePlay(). I can get it to pause the game, but coming back out is where Im stuck. I dont know what code to put in there to make it continue where it was without causing issues with the rest of the game.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo

Login to post a reply

Server time is: 2024-07-02 09:16:26
Your offset time is: 2024-07-02 09:16:26