Main Menu

The great animation debate.

Started by kevin, February 05, 2006, 01:16:37 PM

Previous topic - Next topic

kevin

The great animation debate.

  Implementing animation/movement can be a tricky one,  not that it's difficult to set up, it's difficult to introduce in such a way that's flexible and doesn't blow out the instruction set.  But that i mean, if it requires more set up code than simply using an array, then I fail to see the point.  (made that mistake before :( )

 While I have more than few ideas already on the subject, it seems to be a popular quest.  So lets try ( civil like) and document a possible frame work.  I know that's going to be difficult given there's some future design issues you don't have atm, but ignoring those for the time being, fire away!

 Note:  If your going to make a suggestion, please document/provide possible command examples of how you ideas could be implemented.

Ian Price

To be perfectly honest, there's nothing I can't do animation-wise with PlayBASIC, so I don't feel that I need additional commands/programming.

Loading an animation image (lots of frames in one image) could be a little easier, but I've written my own function to do this (very similar to your own too, Kevin) - with this I can load in fonts too. A command like LoadAnim("XXX.PNG",Height,Width,Number of frames) would make it easier for beginners, but like I said a function to do that is pretty easy and is out there in the examples already.

As for actual animations, there really is only a need for two ways (that I can think of right now).

1. All the frames of a certain animation are loaded into memory sequentially (either individually or as above(from an multi-anim image)) and then shown sequentially -

eg.

anim=anim+1

If anim>max_anim Then anim=0

Drawimage anim,x,y,1


2. All frames are loaded into memory, then use an array to draw image based on a value

eg.

Dim walk(10)

walk(0)=7
walk(1)=5
walk(2)=6
walk(3)=5

anim=anim+1

If anim>3 Then anim=0

Drawimage walk(anim),x,y,1


I don't think the principals are any different in any other language really - I used the same code in AMOS, Div, Blitz etc...

Perhaps beginners just need an example/tutorial showing how to use the above code in a practical way.

I was a moderator at Div Arena for a few years and "How do I animate my character?" was probably one of the most frequently asked questions (together with - "When is DivDX coming out?" :P

The way I see it is that many beginners think that animation is actually quite difficult - often because they've heard/read that arrays are required. It's not because they can't do animation, but usually because they don't understand arrays at that point.

However drawing the animation frames in the first place... (Prehaps you could code a command/function to do all the drawing for you... ;) :P)
I came. I saw. I played some Nintendo.

Fash

To be fair I've been using the animation function you gave in reply to a thread in the beginners forum.
Maybe a similar command to "loadanimimage" like blitz could be used (not that I want to see pb become blitz per se)..


counter=0
LoadAnimsprite ("graphics\bluesplash.png",56,36,0,8),1

(imagefile, width, height, first frame, number of frames),spritenumber

do
cls 0
Drawsprite 1,200,200,counter
sync
loop

(sprite number,x,y, and counter would be the frame number of the animation, so you could animate the frame you wanted...eg

counter=counter+1
If counter>7
counter=0
endif


However if there is an easier newb function that does this please let me know...as I'm still new to PB..

Thanks,
Steve
For PC game/demo music visit
Future Developments

Calypson

just add a flixible animation command already, kevin.  It's something that is used way too often and in way too many scenarios to not have a command.  It would cut down on programming time a lot with most games requiring animation (which is the majority of them).  It also tends to sloppify your code otherwise.

Ian Price

I came. I saw. I played some Nintendo.

kevin


Quotejust add a flixible animation command already, kevin.  It's something that is used way too often and in way too many scenarios to not have a command.  It would cut down on programming time a lot with most games requiring animation (which is the majority of them).  It also tends to sloppify your code otherwise.

Like what ?


Calypson

I dunno, thats your job.  maybe attach it to the sprite commands such as...

Quote
spriteanim sprite_index, Image_Index, frames_across, frames_down, transparency
sets an animation image to a sprite.  It would automatically separate the frames from the image ready for use.

playsprite sprite_index, start_frame, end_frame, anim_speed, loop
Plays the animation currently assigned to a sprite from a start-frame to an end-frame. If no animation is loaded to a sprite, it will of course maintain it's current image.  Anim_speed could be negative or positive to play animations backwards.  Loop tag can be on or off.  If off, it will only play through once.  If on, it will continue to loop untill you call the command, "stopsprite"

stopsprite sprite_index
stops the animation of a sprite.

setspriteframe sprite_index, frame_number
stops the animation of a sprite if animation is playing, then sets the current frame-image for the sprite. (could be used for sprite idle frames)

or if you wanted it to be even more flexible, I guess it doesn't have to be directly connected to sprites, but create a new entity called "anim" that would be treated virtually the same as images, although the language handles all the animation for you.  Parameters would basically be the same as before. commands might look like...

LoadAnim
PlayAnim
StopAnim
SetAnimFrame

which could then be used in conjunction with sprites like so...
spriteimage sprite_index, image_index or anim_index.

or could be used with any other sort of thing that requires images.  Just an Idea.  I'm not entirely sure how playbasic works under the hood, so bear with me.

stef

Quotejust add a flixible animation command already, kevin.  It's something that is used way too often and in way too many scenarios to not have a command.  It would cut down on programming time a lot with most games requiring animation (which is the majority of them).  It also tends to sloppify your code otherwise.   

It's my opinion too.


Quote
LoadAnim
PlayAnim
StopAnim
SetAnimFrame


Good point of departure

Kman1011

#8
QuoteI used the same code in AMOS, Div, Blitz etc...

I think AMOS used something called AMAL (Amiga Animation Language) but I forget how it worked

It used to update all animations in the main loop and set up by code like - AMAL(Animation,Frame)...etc.

But it would be great to see some animation commands like I saw in this thread.

Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

Ian Price

I used AMOS - I just wrote a custom routine to handle the animation - negated the need to repeat sprites within the sprite editor. I never bother with AMAL. AMOS PRO was cool.
I came. I saw. I played some Nintendo.

kevin

   Amal in AMOS was interrupt + Multiplexer driven.   It had mini script language for sprites interupts.    While i wasn't personally a fan of it in particular, it did address the bigger issue regarding animation, that is it gave users a way to tie frame cycling and movement and events together.

   This is what animation system should strive to solve.



QuoteI dunno, thats your job.

  erm, See first post ! :)

Quotespriteanim sprite_index, Image_Index, frames_across, frames_down, transparency
sets an animation image to a sprite.  It would automatically separate the frames from the image ready for use. 

  And what about people who don't store their artwork on a single surface,  have odd size frames or use frame handles ? 

Quote
playsprite sprite_index, start_frame, end_frame, anim_speed, loop
Plays the animation currently assigned to a sprite from a start-frame to an end-frame. If no animation is loaded to a sprite, it will of course maintain it's current image.  Anim_speed could be negative or positive to play animations backwards.  Loop tag can be on or off.  If off, it will only play through once.  If on, it will continue to loop until you call the command, "stopsprite" 

  So if play sprite enables  the animation.  Then what  actually steps the sprite frames.  As the user would need to 'step' the animation of sprite either manually (best solution). It could occur during  Sync (Anim speed tied to video refresh speed) or while Drawing the sprite (drawing the sprite more than once would 'double/triple' it's animation rate).


I really would like to avoid implementing another black box solution that could be replicated in PB code. 

Play Anim Chit Chat 



Cheeslord

I enjoyed AMAL because it acted like parallel code, so you could have all these sub-programs running to handle your animation (though when the strings got very long I started getting wierd things happening)

Anyway, you're right, the best thing is for someone to write a set of functions and psubs to handle animated sprites, so you just call psubs instead of using commands (of course you would need a "handler" psub in your main game loop to actually handle the updates).

Mark.

Kman1011

I think the only time I used AMAL was for simple map animations. 

Very cool of PB to implement a series of map anim commands. :D

Although having a few problems with world collisions.... Grrrr! >:(
But that's another thread...(see Getting error message)
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

Andreas

I used  AMAL. I loved  AMAL. Took my small crappy games and made there presentation value go through the roof.

Having your sprites act before a level starts, like watching your girl get kidnapped and getting pissed of about it, was very easy.
Script many  anims together and put some sound events in there.

But if you got one mistake in your script string.
One little typo in your blockbuster movie AMAL script. You got an error pointing at the entire script.
Mistake made in there somewhere... :P Fetch..

andreas

The best thing about making space shooters is that space, is easy to draw.

Vee

Quotespriteanim sprite_index, Image_Index, frames_across, frames_down, transparency
sets an animation image to a sprite.  It would automatically separate the frames from the image ready for use.

playsprite sprite_index, start_frame, end_frame, anim_speed, loop
Plays the animation currently assigned to a sprite from a start-frame to an end-frame. If no animation is loaded to a sprite, it will of course maintain it's current image.  Anim_speed could be negative or positive to play animations backwards.  Loop tag can be on or off.  If off, it will only play through once.  If on, it will continue to loop untill you call the command, "stopsprite"

stopsprite sprite_index
stops the animation of a sprite.

setspriteframe sprite_index, frame_number
stops the animation of a sprite if animation is playing, then sets the current frame-image for the sprite. (could be used for sprite idle frames)

Exactly those commands exist in Darkbasic and I find them quite useful. Though I wouldn't need playsprite and stopsprite.

QuoteAnd what about people who don't store their artwork on a single surface,  have odd size frames or use frame handles ?
They can still handle that stuff the old way.