Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gf11speed

Game SPEED help !

This topic is 6171 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 wrote a game, and on 1 of my test systems ( the faster one) the game runs too fast, and on another system (the slower one), it runs just right. However, when I add StartClock(), WaitClock() commands to slow it down ONLY if necessary, it runs ok on my faster system but too slow on the slower... so what can I do about this? Also, when I add any kind of Wait command, my animations are not smooth at all (like when I slide a bitmap across the screen). How could I fix all this ?? Thanks! *==================* www.syntasoft.com *==================*

Share this post


Link to post
Share on other sites
Advertisement
Here''s how I solved the timing problem for my own prototype/test games (real simple, but it works) - First declare some kind of variable for the specific animation or entire game screen frame, that needs a timer controlled progression. Let''s declare this variable as Time1:LongWord; for now (Pascal code, Delphi 5 compliant. LongWord is unsigned 32-bit, in case you need to know...). Next, you need to write the timer code so that it encapsules the animation code. Let''s assume that the function GetTickCount returns how long your computer''s been on (in milliseconds). Here''s some pseudo-code (Pascal):

if GetTickCount - Time1 > 70 then begin
...Animation code and other instructions goes here...
Time1 := GetTickCount;
end;

What is done in the code above, is that it checks if the difference between GetTickCount and Time1 is larger than 70. If it is, then it first executes any instructions that needs that specific timing, then it assigns the current time to Time1. This will produce a seemingly smooth timing. As you can see, if the test system running your program is too slow to produce minimal results, the timer code will execute as many times as it possible can, because the if...then difference check comes out larger than 70 continously. It is required that there''s a main timer executing the game main loop, for this to work.

More pseudo-code (simple game loop example, where the game loop and everything is coded or called from the timer event procedure):

var Time1: LongWord; //This is a global variable (faster)

procedure TimerTimoutEvent;
begin
Timer.Enabled:=False;
...Game input, sound output and world calculation...
if GetTickCount - Time1 > 70 then begin
...Game animation index calculation and screen output...
Time1 := GetTickCount;
end;
Timer.Enabled:=True;
end;


Hope this works,
good luck!

-cyberium

Share this post


Link to post
Share on other sites

  • 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!