Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Move Pacman/Snake automatically  (Read 1795 times)

0 Members and 1 Guest are viewing this topic.

vamsi360

  • Newbie
  • *
  • Posts: 3
    • View Profile
Move Pacman/Snake automatically
« on: February 11, 2012, 09:26:04 pm »
Hi,

I have developed a pacman game in SFML.

The pacman is moving through the grid now only when the keys are pressed.

How can I change that to move Pacman move automatically one block of a rid at a time? That is, the pacman will be moving and arrow keys are only used for direction change. This is the behavior in a normal pacman or a snake game.
I have used delay and sleep only to end up unsuccessful.

Please help me.
Future belongs to the king and AI is the king.

TheCake

  • Newbie
  • *
  • Posts: 19
    • View Profile
Move Pacman/Snake automatically
« Reply #1 on: February 13, 2012, 12:15:22 pm »
Hi,

What you should do is setting the direction where your pacman is moving with the key events and then, update your pacman position every X milliseconds in your main loop.

Here is a good article on different implementation of game loop and timing : http://www.koonsolo.com/news/dewitters-gameloop/

 

anything