Hello all,

I've been wondering what would be best to method to create
animations in my game. Basically I got 2 idea's:

First one would be a bunch of Timers, the other one would be a
thread. Latter one seems cleaner but should I insert a Sleep(x) at
the end of the function to create the animation delay?

If any of you guys got some experience in this area, I would
appreciate any kind of advice.

Posted on 2001-11-23 13:08:44 by JimmyClif
Do all the calculations yourself - don't use timers or threads. Create a simple sprite language:

flags dd ? ; in-/active, type, etc...
rate dd ? ; time base for motion
images dd ? ; list of images
motion dd ? ; all kinds of motions are possible
Sprite ENDS
Just get the time, then enter a tight loop testing for what sprites to update. You might want to put this in it's own thread, but don't create threads for each sprite.
Posted on 2001-11-23 13:34:33 by bitRAKE

Using a Struct is a great idea... but I'm chewing a little bit on the "just get the time" ;-)

I mean, I probably have to update all my sprites every 1/2 second.
Do you mean sthg like this?

; Initialization
|-> retrieve milliseconds
|-> store in A

|-> retrieve milliseconds
|-> store in B
add 1000 to B ; in case the second increased and B was set to 0
substract B from A
IF B >= 500
update sprites
|-> retrieve milliseconds
|-> store in A
restart @LOOP

Or is there an easier way and I'm just too blind to see it?

Posted on 2001-11-24 01:34:55 by JimmyClif
That could work, but my approach is to get the CPU speed at the start of the program to create a gametime constant, then use the performance counter. :)

div GameTime
mov ebx,eax
sub ebx,LastTime
mov LastTime,eax
; TightSpriteLoop
@@: sub [esi].MySprite.time,ebx
js UpdateSprite
add esi,SIZEOF MySprite
dec ecx
jns @@

mov eax,[esi].MySprite.rate
add [esi].MySprite.time,eax
This is a work in progress...
Ask some more questions and I'll add more tomorrow...
Posted on 2001-11-24 01:50:22 by bitRAKE

Gimme a couple of days to try this out.

I'm getting married in a couple of days and next days are more or less "unique"...

As soon as life returns to normal I 'll try it out and give you any feedback :grin:

Thanks a lot tho :alright:

See you in a couple of days ;-)
Posted on 2001-11-24 23:36:46 by JimmyClif
Heya BitRake,

Sorry for the wait...

I tried out the QueryPerformanceCounter and QueryPerformanceFrequency. Latter one gives me the Number of TicksPerSec. Got that :-) First gives me an ever increasing number. I see how I can get my game based upon this. ( I guess it's even faster than GetLocalTime)

Well, stupid question last: Does it stop and restart at 0 after FF.FF.FF.FF?

And how do you use that rdtsc thingy?

Thanks for the help && patience :)
Posted on 2001-12-17 20:25:33 by JimmyClif
rdtsc returns a 64-bit number in EDX:EAX and yes it wraps around, but on my 1.34Ghz processor that would take 438.5 years. This value can be changed, but the game will be fine after maybe one strange frame. :)
Posted on 2001-12-17 20:52:41 by bitRAKE

(there is a warm body in the other room calling my name - she wasn't wearing much last time I looked. )

Posted on 2001-12-17 21:28:39 by f0dder
There is only one thing that pulls me away from coding...:grin:
Posted on 2001-12-17 23:03:34 by bitRAKE