Sprite Animations

Advanced game related topics
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Sprite Animations

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Re: Sprite Animations

Post 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.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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!
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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).
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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.
Brice Manuel

Post 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?
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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
Brice Manuel

Post by Brice Manuel »

Thank you for answering. Are you by any chance still working on your Irrlicht 3D port for PureBasic?
Post Reply