Jump to content
  • Advertisement
Sign in to follow this  
DOS4dinner

2D hardware dependency question.

This topic is 3672 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been working on creating a simple little game (if you could call it that) where it is 2D, has a little square dude, and he can move around and basically test if my collision detection works. Hopefully, it will turn into a 2D game of some sort, but for now I am just trying to get it working. (Don't worry, I am not trying to recreate Super Metroid in my first project...I know a full 2D game is a lot of work) Anywho, I have question: How do you prevent things from becoming hardware dependent? I.E. If you have a jump function, how do you prevent it from looking nice and working correctly on one machine to doing it so fast the user cannot see it on their quad-core processor super computer? I am using C++ and SDL, if that changes how you do it. EDIT: Sorry if it was confusing, I did not mean if my program would run on other hardware, it is at the SPEED of which it would run. By "hardware dependent" I meant "only able to run at the right speed on my machine--on others, it may run too fast". [Edited by - DOS4dinner on July 31, 2008 7:46:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by DOS4dinner
How do you prevent things from becoming hardware dependent? I.E. If you have a jump function, how do you prevent it from looking nice and working correctly on one machine to doing it so fast the user cannot see it on their quad-core processor super computer? I am using C++ and SDL, if that changes how you do it.
Through correct timing. The simple way is to use the time since the last frame to adjust the movement of objects (i.e. if it is 1/30 sec since last frame, move an object by 1/30 of a tile). A more robust method is to ensure to always perform logic at a fixed rate - say 30 times per second.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by DOS4dinner
How do you prevent things from becoming hardware dependent? I.E. If you have a jump function, how do you prevent it from looking nice and working correctly on one machine to doing it so fast the user cannot see it on their quad-core processor super computer? I am using C++ and SDL, if that changes how you do it.
Through correct timing. The simple way is to use the time since the last frame to adjust the movement of objects (i.e. if it is 1/30 sec since last frame, move an object by 1/30 of a tile). A more robust method is to ensure to always perform logic at a fixed rate - say 30 times per second.


Seems simple. How would you code, for instance, increment a varible by 10 twice a second?
Would it be (rougly) like this?:

get time;
if(time is one second greater)
{
variable += 10;
variable += 10;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by godsenddeath
c++ is not a hardware specific language, so it's not a concern, at all


Might also be important to note that SDL...not so much as doesn't but can't use hardware. But, even if you used DirectX or OpenGL (hardware solutions), it's unlikely that someone without a compatible video card would play your game. (However, one problem is that Vista users might not be able to play your OpenGL game if you use an update version of OpenGL--I don't know if it's all of the newer OpenGLs or just certain features.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!