Click to See Complete Forum and Search --> : slow down sprite
erickd00sway
December 7th, 2005, 12:52 PM
Hello, im trying to write a game along the same lines of pacman in c++, i need help on how to actually slow pacman down when he collides with a certain sprite. i want him to not be able to move as fast for a set number of seconds... does anyone know how this could be done? many thanks
erick
wuhoo
December 7th, 2005, 01:35 PM
why does Pak-man need to slow down when colliding with another sprite..
What are you trying to accomplish...
erickd00sway
December 7th, 2005, 01:43 PM
sorry, i have put in a sprite for pacman to avoid, and if he hits it, i.e if the ghosts block him and he has to hit it, then he will be slowed down for 5 seconds or so.
does that make in any clearer?
wuhoo
December 7th, 2005, 01:53 PM
you probably have a 2d array of sprites representing the game board.
Each index of the array has a corrosponding pixel height/width
some sprites happen to move, and these would have velocity associated with them..
When you move you take the current pixel position of the sprite and add/subtract its velocity(depending on direction) to find the next pixel position.. Then you can use that position to determine where the sprite is in the array...
In short, your movable sprite should have a velocity member that you use to determin its next position, just have a 'setter' function and slow your guy down....It may be important for your new speed(or any speed that your movable may travel at) to divide evenly into the predetermined size of each 2d array index...
i hope that makes sense
erickd00sway
December 7th, 2005, 01:56 PM
something to work on, many thanks guys
Marc G
December 7th, 2005, 03:19 PM
[ moved thread ]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.