🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

speed of game?

Started by
6 comments, last by ViPeR007 24 years, 5 months ago
Does anyone know of a better way of setting the speed of your game other than the Wait_Clock(30); way? Im only asking because the Wait_Clock varies on systems (like the speed will be different in a game when your running it on a 400MHZ or a 200MHZ). Thanx, ViPeR
Advertisement
I read Spur''s post down below and I understand why you would want to base movement on pixels and not on frames but how would you go about doing that? (Im using the GPDUMB engine from Andre Lamothe''s book)

Thanx again,
ViPeR
Actually I thought that the Wiat_Clock function got the systems current time, and I don''t see how seconds on one computer would be faster on another.

Visit http://members.xoom.com/ivanickgames
Visit http://members.xoom.com/ivanickgames
Well it must do something because on my 500MHZ it runs normal but on my 200MHZ it runs slow, very slow or dare I say laggy. This is a 2d game (space invader clone), so it shouldn't need a very powerful computer to run it.

Thanx,
ViPeR

Edited by - ViPeR007 on 1/18/00 7:07:10 PM
I think it works fine, but there are two many variables. First, your second computer might be using system memory instead of video memory. Second, Lamothe''s engine is REALLY slow by any real standards. The Wait_Clock does no set a minimuc framerate, only a maximum. Therefor your 500 is finishing with time to spare and waiting, but your 300 is finishing way past the 30ms limit and straggling behind. My advice? Base the amount of movement on time passed.
Does using system memory slow down a game that much (instead of using video)?

Thanx,
ViPeR
I think your problem may have to do the fact that on your 200 speed computer, the amount of time it takes to go through the main game loop is longer than how long the wait clock is set to. If this is the case then you will have to to one of two things.
1) Let it run slower on slower machines
2) increase the amount of time in wait clock, this will slow down the speed on faster computers but also alowing for both slower and faster computers to run at the same speed.

Hope that helped.

Spike
~SpikeYou can contact me at luke_howard@dingoblue.net.au
You should really try to set velocities to units per second rather than units per frame. So rather than move the object 10 pixels after every Wait_Clock call, define a constant velocity, say 40 pixels per second. Then after every frame, calculate how many milliseconds passed since the last frame, and adjust your object accordingly. i.e. if 500 milliseconds passed, move the object 20 pixels. This results in smooth animation.

This topic is closed to new replies.

Advertisement