C++/SDL: Images moving too slowly. Images loaded once, etc. Why?
I am looking at games on the Super Nintendo, NES and etc., and I noticed how smooth their backgrounds and other objects move across the screen. I'm trying to recreate that after a couple unsuccessful attempts. I have made a small program that just moves a stick man across the screen everywhere, except where some blocks are at.
http://www.yousendit.com/transfer.ph...E52A1E3A0EF883 Just execute sc_game and you can see what I mean. I am trying to get speed variation in my objects. So far, to get that smoothness I see in 2D games, moving images one pixel at a time across the screen using a specific time frame for each image sounds like the best way to achieve this. The problem with the above application is that it does not use a time frame. And strangely, it is running strangely slow. Why? Am I supposed to move images across the screen by the pixels (instead of one) along with a time frame? Thanks in advance. |
Currently your object "blob" just updates positions using a defined offset
Code:
void scobject::move () Using a fixed time step can help in making a game run the same no matter what the machine specs are, where as a variable time step gives differing results. Code:
struct Object Here is two links from Glenn Fiedler that you should read: http://www.gaffer.org/game-physics/fix-your-timestep/ http://www.gaffer.org/game-physics/integration-basics/ |
Thank you, I am implemented time based movement into my game.
|
All times are GMT -5. The time now is 05:57 AM. |