Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

timers in games...

Name: Anonymous 2006-09-30 18:16

so the only games I've written so far were all turn-based games.

I'm now going to try my hand at a real time game.  Nothing fancy, probably nothing fun either, just something to expand my know-how a little bit.  I've so far written an .md2 loader/viewer that animates the various animations of a model, but the animations are freakishly fast, more than they're supposed to be, due to the computer's speed

how do I go about starting off a game's main loop like this such that an uber-fast CPU doesn't cause everything to happen in the blink of an eye?  And what about making it somewhat tolerable to run on an underpowered computer without it bogging down the system (Quake 1 on my old old old 486 computer was playable in this regard... it seemed "real time aware" even if it was a slideshow, so an ogre would run the same speed in the world regardless of the graphics' framerate). 

I also probably want to not just make it smooth on a fast CPU but also throttled -- sure, it CAN render 300 frames per second, but I want to be able to cap that to 60fps as a maximum.

are there any reliable books I should look for that go into decent enough detail this subject?

Name: Anonymous 2006-10-26 18:46

>>33

What am I supposed to be looking for?  The clock() function?  Guess what:

 APPLICATION USAGE

    In order to measure the time spent in a program, clock() should be called at the start of the program and its return value subtracted from the value returned by subsequent calls. The value returned by clock() is defined for compatibility across systems that have clocks with different resolutions. The resolution on any particular system need not be to microsecond accuracy.

    The value returned by clock() may wrap around on some systems. For example, on a machine with 32-bit values for clock_t it will wrap after 2147 seconds or 36 minutes.

LOL... that will certainly fuck things up.

From what I found from Googling, timers are very OS and hardware specific.  I'll just have to write a transparent Timer wrapper class of my own and finish this program in Windows... then when it's finished and I port it I can change the internals of the Timer class to whatever other platform I port it to without having to change much else elsewhere in the program.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List