My SDL Animation App

Started by
7 comments, last by superpig 19 years, 4 months ago
Ok I did not like how cone3D does animation. So I wrote my own animation algorithm. It works. Note that this has no timer in it lol. And this image does not move it just floats there and flies lol. A few modifications for instance will make this much more efficient but this was my first SDL app without the use of a tutorial so I figure I would just crack something simple out. Here it is. Oh and of course tell me what you think. I will include the Cpp in the distro if you want to look at it. Anim.zip [Edited by - TheNobleOne on December 3, 2004 8:12:08 AM]
My JournalComputer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. (Eric Raymond)"C makes it easy to shoot yourself in the foot. C++ makes itharder, but when you do, it blows away your whole leg."-- Bjarne Stroustrup
Advertisement
Humm... nobody has any opinions ?
My JournalComputer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. (Eric Raymond)"C makes it easy to shoot yourself in the foot. C++ makes itharder, but when you do, it blows away your whole leg."-- Bjarne Stroustrup
Nice one dude! That's pretty much how I do it.
An extension you could try adding is allowing multiple animations per sprite, and also instead of just incrementing the frame number, you can use an array of indexes so that you can control what order you draw them in, that way you can have more than one animation in the same image file.

Keep it up!
Quote:Original post by TheNobleOne
Note that this has no timer in it lol.
How do you animate without a timer?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

By using SDL which runs at 60 fps if not lower anyway :P
http://sourceforge.net/projects/pingux/ <-- you know you wanna see my 2D Engine which supports DirectX and OpenGL or insert your renderer here :)
That's just using the screen refresh as a timer [smile]

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Quote:Original post by PinguinDude
By using SDL which runs at 60 fps if not lower anyway :P

not true.

Only runs that slow if vsync is turned on.
All I do is basically use SDL_Delay after rendering each frame and then after that increment to the next frame then do it again.
My JournalComputer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. (Eric Raymond)"C makes it easy to shoot yourself in the foot. C++ makes itharder, but when you do, it blows away your whole leg."-- Bjarne Stroustrup
Quote:Original post by TheNobleOne
All I do is basically use SDL_Delay after rendering each frame and then after that increment to the next frame then do it again.
Ah. You do realise that that'll cause the animation to play at different speeds on different computers under different operational workloads at different times in different ways?

The reason people use timers for this kind of thing is because it ensures the animation won't play back stupidly fast/slow on machines different to the development machine.

[edit: well, if you're using SDL_Delay it shouldn't run faster than normal, but if your framerate drops it'll run slower.]

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement