Count-Down Timer

Hello! I’m trying to make a pacman style game and I wish some help in a few steps that I’m not able to do it by myself. At least I don’t know the answer to but it should be easy.

So far, I’ve all the scene set up and working (the ghost runs away from the pacman and all the points are being count so are the lifes - when reaches 0 the game ends or all the points eaten). This are things I would like to know how to solve:

I have a powerup food so when eaten I want the game to reverse (like the original game) so the ghost runs away from me for a short time let’s say, 10 seconds and pacman can eats it wining a few points, and then revert to the normal (ghost seeks pacman if not eaten). How can I do this? I set a message to the colision with the powerup and then the ghost receiving the message but after that I don’t know what to do.

I never made a python script so if needed I would be glad to have some step-by-step guide.

Thank you so much!

timer property (it always counts seconds upward)

Use a time property like monster said, and multiply it by (-1) and then add x where x = the starting amount of time. That way, the new value will count down from 10 (but will not stop at 0)

timer allways count upwards. give it a starting value of the time you want to count. e.g. 10 if you want a countdown of 10 seconds. this is necessary because you dont want the hunting ghost state from the beginning. the timer runs up. now if you eat a fruit in pacman, set the timervalue to 0. the only thing you need now is an actuator that changes the state of your game: hunting ghost or beeing hunted. whenever you eat a fruit the timer will be set to 0.

Attachments

timer.blend (444 KB)

Thank you for the reply. Can someone explain how to revert the game? For an instance, I want this steps:

  1. Pacman eats powerup
  2. Countdown of 10 seconds appear on screen
  3. The ghost runs away and can be eaten in the meantime
  4. As soon as the timer goes back to 0 the game reverses to normal and the ghost will seek pacman unless it died.

give pacman a gamestate boolean property. name it for example “eatGhost”. startvalue false. set it to true and when pac eats the fruit and set the timer on 0, set the boolean to false when the timer is greater than 10. let the ghosts copy the boolean property and let them act like the state lets them act, run away from pac when the state is true and run to pac when it is false.