Skip to main content
GameDev.net gamedev.net
🔒 Locked

Speeds

Started by Ructions Mar 3, 2004 at 5:19 AM 9 replies 650+ views
Original Post
Ructions
Ructions
I am writing a arkanoid type game. I was wondering why when i run my project on my machine which has a 550mhz it runs faster than a machine which is 1.5ghz. Is it something to do with operating system as my machine is windows 98 while the other pc is window 2000. I want my game to be able to run on all modern machines in the same way.. Any information to help would be greatful. Thanks Ructions
fractoid
fractoid
It might be a system timer resolution issue - for instance, Win98 has a timer resolution of 16ms (~62 / sec) and I *think* Win2K lowered that to 1ms (~1000 / sec). The system sleeps your thread for the minimum number of realtime-clock ticks that cover the requested time. So, if you''ve got a Sleep(20) then on Win98 it''ll run at 30fps but on Win2K it''ll run at 50fps.

Is this consistent with what you''re seeing, or am I talking out of my ass?
Ructions
Ructions
I am not using that sleep function at all. so can i have somewhere in my code then to say that what ever operating system make it sleep a certain amount of time. or am i taking it up wrong. Or does anyone else have an idea how to make everything the same..

Thanks
Ructions
fractoid
fractoid
Eeek. OK, I assumed you had a Sleep() somewhere in there to limit your game''s framerate. If you aren''t using that (or anything else such as GetTickCount() which also depends on the system timer) then I guess it''s time to do some profiling...

Basically, something you''re doing is taking different amounts of time on the different operating systems. Common things to suspect would be processor, graphics card, and any artificial speed-controls such as sleep(). It''s not the processor (because it''s being weird and going backwards) so it may be the graphics card (although I doubt arkanoid would faze any moden gpu - does this game use an API like Direct3D or OpenGL? or does it do bitmap -> StretchDIBits() or something?)

How does your main game loop work? Are you using system timers? I had nachos for lunch today, and they always interfere with my psychic powers, so...
Ructions
Ructions
I am using OpenGL.

My Game Loop is the same as the OO base code on this weeksite.
I just seen that it uses GetTickCount(). But i am not using it in the Update Function even though the tickcount is passed to the functions. That is probaly the problem but how do you
in corperate the tick count in the update function.

Thanks
Ructions

fractoid
fractoid
Umm. OK, I''ve had a look at the basecode, and I can''t see why that would be slower on a fast machine than on a slow machine... so I guess it''s not a system-clock-resolution issue after all. I should have asked this ages ago, but which machine was running Win2K? Does the machine that runs the game slowly have a decent graphics card (ie. can you play 3D games on it)? Does it run other NeHe tutorials OK? It might be as simple as the video card not supporting OpenGL, thus doing all software rendering, which tends to be slower than hardware even on a fast machine.

Sleep time now - back tomorrow. Good luck!
Ructions
Ructions
So does anyone else have any ideas.
When the tickcount is passed to the update functions what are you ment to do with it. as i dont do anything with it.

Thanks
ructions
Allmight
Allmight
Well, you basically use the TickCount as a tool to make sure
the game runs at the same speed on all types of machines. What
you do is call it once every frame, compare the result with the
result from the last frame, and take apropriate actions based
on the result.

You can also use that value generated in the TickCount function
to calculate the current framerate of the app.
-------------------------------------------------Founder and DirectorAllSoft Studios
Ructions
Ructions
I understand that but what apropriate actions do you do. i get the tick count but thats it i dont do anything with that value.
Kurioes
Kurioes
With GetTickCout you can measure the amount of time that passes per frame. You can then make sure any object moves a certain distance per second.

Example:

float timepassed;
unsigned int timer = GetTickCount();
float playerx = 0;
const float playerspeed = 40.0f; // player speed in units per second

while (playinggame)
{
timepassed = (float)(GetTickCount()-timer) / 1000.0f;
timer = GetTickCount();
if (keyleftpressed) playerx += timepassed * playerspeed;
if (keyrightpressed) playerx -= timepassed * playerspeed;
updatestuff();
drawstuff();
}



I hope this illustrates what you need to do with the GetTickCount value...



[ Galactic Conquest | Bananas | My dead site | www.sgi.com | Goegel ]
Ructions
Ructions
That brilliant. Thanks a million. Ill have fun implementing it. If i have any problems.
ill be back.

thanks again
Ructions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.