Sprite Speed

Started by
4 comments, last by Zeke 23 years, 2 months ago
I have a sprite that moves using the arrow keys the problem is to keep the sprite moving smoothly I have to move it by 1 pixel every frame. This makes the sprite move really smothly however she walks way too slow. I need her speed to be moving at 8pixels a frame and that is the right speed. However if i use 8 pixels then her movement is very jerky. Is there a way i can move her 1 pixel at a time but so she is still moving at a faster speed? I know I havent explained this too well but if anyone can help i would be very much grateful. Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Advertisement
Increase your framerate lock. So instead of locking it at 25 FPS, lock it at 40 or something. This is a simple solution (and probably not the best) but it''s the only one I can come up with at the moment.

==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
I think it''s best to think of sprite movement speed in something like pixels per second. Then when you move the sprite, move it by a factor of how long the last frame take to complete. That way the movement will be locked to the framerate so the sprite will always move at the same speed across the screen regardless of the framerate. Although you should cap this if the frame rate drops too low.
For sprite based games, the refresh needs to be around 50FPS as a minimum to appear smooth. 30FPS looks very jerky for 2D sprites. 3D on the other hand looks fine at 30FPS (or even down to about 20), but looks really good at 50/60FPS.
Gee Brain, what we gonna do tonight?
You can even drop the FPS altogether. In my sprite based game, I dont restrict to a specific frame rate. I simply update whenever I can, and move sprites based on time elapsed, not a constant motion per frame.

This way, if their computer is fast enough, even fast motion can be smooth (moving 1 pixel at a time). On the other hand, If the Update() function doesnt get called as often, it may only move 2 pixels at a time (but the over all speed remains the same, it is just the granularity of the motion that changes).
quote:
You can even drop the FPS altogether. In my sprite based game, I dont restrict to a specific frame rate. I simply update whenever I can, and move sprites based on time elapsed, not a constant motion per frame.



same here, the mover''s veloctiy is measured in units/second, and in the update func i have:

position += velocity * timedelta; //timedelta is in seconds as is the time elapsed since last update
Thanks guys. I''ll have a go at the pixels per second rather than pixels per frame idea. Cheers
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

This topic is closed to new replies.

Advertisement