Resolved-Pause problem
by Christian Rademan · in Torque Game Builder · 10/19/2007 (12:29 am) · 5 replies
I need help with my pacman.
When my player dies I want to start a new round. Not a level, just a round where I respawn the player and the ghosts in their starting positions.
Then I pause the game for three seconds and display a "READY!" message. Then After 3 seconds I unpause the game and everything starts moving.
In my newround function I first pause the game then call the spawn function for the ghosts and my player.
The only problem is that sometimes when the game is paused not all of the ghosts have been returned to their spawnpositions or their eyes are left behind. Or the player is still where he died.
I am confused about the flow of things in TGB. Can anyone point me to some info on this?
Thanks a lot.
When my player dies I want to start a new round. Not a level, just a round where I respawn the player and the ghosts in their starting positions.
Then I pause the game for three seconds and display a "READY!" message. Then After 3 seconds I unpause the game and everything starts moving.
In my newround function I first pause the game then call the spawn function for the ghosts and my player.
The only problem is that sometimes when the game is paused not all of the ghosts have been returned to their spawnpositions or their eyes are left behind. Or the player is still where he died.
I am confused about the flow of things in TGB. Can anyone point me to some info on this?
Thanks a lot.
#2
I mount the eyes to the ghost body for simplicity.
The ghost eyes are always visible, so when the ghost dies I just make it invisible. I only have one ghost animation and one imagemap for the eyes. I just set the blend color for each different ghost.
And if the player eats a powerpill I just set the blend color to light blue.
Saves on having to create a different animation set for each color ghost etc.
10/22/2007 (1:35 am)
Thanks David. I mount the eyes to the ghost body for simplicity.
The ghost eyes are always visible, so when the ghost dies I just make it invisible. I only have one ghost animation and one imagemap for the eyes. I just set the blend color for each different ghost.
And if the player eats a powerpill I just set the blend color to light blue.
Saves on having to create a different animation set for each color ghost etc.
#3
10/24/2007 (2:40 pm)
Just as an FYI, if you're using schedule calls, they won't be affected by pause function in TGB. So David is correct that a global flag is probably your best route. :)
#4
10/24/2007 (6:18 pm)
As a side note -- if you use the schedule manager resource, you can easily manage your schedules and pause them when appropriate -- tying this into your logic for pausing the game is quite simple -- but 'pausing the game' is not the route to go for this problem still ;)
#5
10/24/2007 (10:39 pm)
Thanks all. I will take a look at the schedule manager resource.
Associate David Higgins
DPHCoders.com
Instead, implement some sort of an 'active' flag in your Mobile objects.
Both Pacman and the Ghosts should be derived from a base class, as they share a lot of characteristics. You can then have some sort of a game-level flag that indicates whether or not mobile objects can move, this movement is independent of the layered artwork ('the eyes are left behind' implies your layering eyes on top of the ghost bodies -- not sure why?)
Then, implement a simple 'respawn' function -- which uses a field in the base class to determine where the object respawns too (X/Y coords on grid, word position, or whatever your using to determine position).
Then, move your object, along with all of it's other items -- display your 'ready' text, and set a 3 second timer which hides the 'ready' text and flips the 'active flag'. Then your game starts again ...
Using the actual 'pause' functionality in the engine will effectively 'halt' everything, and, depending on the state of things when the 'pause' is actually taken into effect (I believe it slowly catches up ... may take 2-3 frames -- hence the objects in odd locations issue) ...
Pausing should be reserved for losing game window focus, or when the user presses a 'pause' key (ESC for example) ... to stop all activity within the game (AI Movement, Player Movement, Score Timers, etc)
Hope this was clear enough?