Page 1 of 2

Sprites and the framerate

PostPosted: Apr 21, 2003 @ 4:01pm
by Karel

PostPosted: Apr 21, 2003 @ 5:18pm
by ppcStudios

PostPosted: Apr 23, 2003 @ 11:15pm
by Karel

PostPosted: Apr 24, 2003 @ 10:00am
by maurice

PostPosted: Apr 24, 2003 @ 12:14pm
by spacemonkey

PostPosted: Apr 24, 2003 @ 2:11pm
by Hosed

PostPosted: Apr 24, 2003 @ 8:26pm
by Karel

PostPosted: Apr 24, 2003 @ 8:57pm
by ppcStudios
Krelis, are you creating a timer for each sprite? I'm not sure I would want to do that. I've not looked into how much overhead multiple timers generate, but it wouldn't seem like a good thing if you're creating a boatload of sprites.

I create a handful of timers of different frequencies at the start of my application, and derive all my sprite timing from those.

PostPosted: Apr 24, 2003 @ 9:29pm
by Karel

PostPosted: Apr 24, 2003 @ 10:12pm
by ppcStudios

PostPosted: Apr 24, 2003 @ 10:51pm
by Karel

PostPosted: May 14, 2003 @ 3:35am
by Guest

PostPosted: May 14, 2003 @ 5:05am
by ppcStudios
The problem with using GetTickCount( ) is the resolution varies from platform to platform. Most WinCE devices have a resolution of ~1ms, NT/Win2K has a resolution of ~10ms and Win95/98/ME is on the order of ~50ms. Using SetTimer ensures you have a stable time base for animation, which is a necessity for reliable, platform independent animation.

[edit]Of course multimedia timers are the preferred way to do animations, but we don't have that option on CE devices. An alternative would be to create a thread that does a Sleep(timeout) then calls a callback function to trigger the animation frame update. This would give excellent resolution and be pretty stable.

PostPosted: May 14, 2003 @ 5:28am
by efortier
Hi. Here is my 2 cents.

What I did was to include both frame based and time based animations.

Frame based for the walking animations of my characters. The higher the frame rate, the faster they walk. I found that the on-screen result was a lot nicer for the characters with frame-based animations.

I use time-based animations for the world objects. So no matter what the frame rate is, and no matter how fast the characters are walking around, the world objects are animated on a steady base.

Now, if timing is important on other platforms than PPC, you may want to take a look at the performance counter. They offer very (very) high resolution. However my understanding is that they are not availailable on all systems. My iPaq 3850 has them. All my PCs have them too (Athlon XP, P3, etc).

Check out QueryPerformanceCounter() and QueryPerformanceFrequency() for more on this. What you could do is make some base timing functions that first try to use the performance counter, if unavailable fall back to GetTickCount().

And there's also timeGetTime() on non PPC platforms. This has been a favorite of mine in the past.

--Eric

PostPosted: May 14, 2003 @ 5:36am
by ppcStudios
Good point Eric... I was just about to post about QueryPerformanceCounter but wanted to verify first that it may or may not be supported on all winCE devices as its an OEM implementation.