|
-
Nov 15th, 2002, 12:42 PM
#1
Thread Starter
Addicted Member
A question on moving sprites
During a game loop, if the user has a key down, i want to move a sprite. Now, i've heard of several ways about dealing with the speed. Should i have the sprite only be moved after so many frames, and then when i want to increase its speed, just move it more often? Ex: move every 10th frame to every 2nd frame. Or, should i just move it more than 1 pixel at a time? This produces some jerkiness and i think would cause problems with collision detection (ie, running over the object its colliding with). thanks for any ideas,
jmiller
-
Nov 15th, 2002, 02:41 PM
#2
I'm not a skilled game programmer, but I have always moved a picture more then one pixel per time to make it go faster. Double are actually nice to work with her, because then you don't have to move 1 or 2 or 3 pixels a time, but maybe 1.5, then it looks like it walks 1.5 pixels each time, but it actually moves 1 pixel the first time, and 2 the next time and 1 the third time, and so on....
-
Nov 15th, 2002, 05:06 PM
#3
Good Ol' Platypus
In this case, find out the time between draws, calculate a ticks-per-second structure, and work out how much you'll have to move this (otherwise on a really fast computer it will move at x pixels/s, and on a slow computer it'll move at y pixels/s, with x any y being the number of frames drawn, etc). So, you need to create an arbitrary value of movement so that you can have the code execute similarly on different spec'd machines.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|