Page 1 of 1

Sprite Animations

Posted: Sat Apr 23, 2005 9:13 pm
by dracflamloc
How do you handle sprite animations in your games? I'm just trying to find the different methods you all use in PB.

Please do not mention Sprite3d in here whatsoever.

Re: Sprite Animations

Posted: Sat Apr 23, 2005 11:32 pm
by Shannara
dracflamloc wrote: Please do not mention Sprite3d in here whatsoever.
Since they are handled the same way, I wont mention Sprite in here at all either.

Posted: Sun Apr 24, 2005 12:02 am
by dracflamloc
Since people may have found other ways to do it using DX structures and Sprite3d, I said to keep Sprite3d out of this thread since I'll be using Linux as well.

Your post was uncalled for and if you don't have something useful to say please don't.

Posted: Sun Apr 24, 2005 12:29 am
by Shannara
I was responding to your flappant remark. If you cant take what you give out, then it's best to keep quiet, no?


Anyways, for myself, if I am aiming for around 60 fps, then I create code much like the following assuming you actually wany 60 frames per second:

Code: Select all

Structure strAnimation
  LastTime.l
  CurrentFrame.l ; Tell the engine what frame we are on.
  Frames.l[60] ; 0 - 59 = 60 Frames
EndStructure

Global Sample.strAnimation
Global myDelay.l

Sample\CurrentFrame = 0
myDelay = 16 ; 16ms per frame = roughly 60 frames per second.

;Load up your sprites for each frame however you do it 
; ..

Sample\LastTime = ;however you set the current time :)

In your game loop, check current time against the last time to see if your myDelay value is reached. If it is, up the frame by one, be sure to make sure your frame does not past 59, or reset to 0 :)

If you set your delay in the structure, you can dynamically change it according to how many frames are used in your animation ...

This is roughly the way I do mine, except for now Im moving to pointers so I wont have to shift graphics around different variables (less lookup time :D).

Concerning the Linux issue, Im running into the same problem :) Thus I use a whole slew of CompilerIfs thoughout my engine whenever Sprite3D is involved. I know it's a pain, but until PB/Linux is uptodate .. :D

Hope this helps!

Posted: Sun Apr 24, 2005 12:33 am
by dracflamloc
I don't see how it was flappant. I just stated to not mention Sprite3d in this thread...

Wake up on the wrong side of the bed? :wink:

Anyways thanks. I was thinking of doing that.
This would be easier if PB was OO but it shouldn't be too hard. Pointers are definitly the way to go here however.

Posted: Sun Apr 24, 2005 12:36 am
by Shannara
Actually, I think I woke up on both sides of the bed, I was doing pretty good about 10 hours ago, hehe. I apologize for my rude response.. argh, gotta love it, eh?

Anyways, there's another way to do animation .. use the PureTools :) Im thinking about converting over, depending on how much overhead and speed penalty there is (if any).

Posted: Sun Apr 24, 2005 12:46 am
by dracflamloc
Maybe I'll just create an OpenGL-based sprite lib for linux and windows.

Won't happen for another at least another 3 weeks because of school though.

Posted: Wed Jul 06, 2005 12:58 am
by Brice Manuel
Maybe I'll just create an OpenGL-based sprite lib for linux and windows.
Still planning on this, or has it been dropped?

Posted: Wed Jul 06, 2005 3:21 am
by dracflamloc
It's been dropped only because pb linux can't even create an opengl window/rendering context =\

Fred says he's made a sprite3d for opengl but its not completed

Posted: Wed Jul 06, 2005 3:29 am
by Brice Manuel
Thank you for answering. Are you by any chance still working on your Irrlicht 3D port for PureBasic?