Animation

BlitzPlus Forums/BlitzPlus Beginners Area/Animation

coach(Posted 2005) [#1]
How do I animate a person, so that he doesn't just float over the ground?


xlsior(Posted 2005) [#2]
1) Make multiple animation cells
2) Instead of LoadImage, use LoadAnimImage and specify the sizes and numbers of cells
3) When drawing your sprite, there is an additional (optional) parameter where you can specify the cell number... So use a counter or timers, and cycle through the different frames when you draw your sprite.


coach(Posted 2005) [#3]
By 'Make multiple animation cells' do you mean draw the person in different stages of movement? What is a 'sprite'? Please explain it more simply(sorry I don't get this; I'm a beginner)?


Grey Alien(Posted 2005) [#4]
1) Lets say your man is 32 pixels wide and 64 pixels tall, this would be 1 frame (a rectangle). You may need something like 8 frames or more (each showing a slightly different picture) to give the impression of walking (animation). So make a bitmap in paintshop pro or something that is 8x32 pixels wide and 64 pixels tall. You will find it useful to draw 8 rectangles (32 pixels wide) side by side on the blank bitmap. Then you can draw each frame within the rectangles. There are also some tricks to making the man walk smoothly (the same amount each frame) but that's for another day.

2) Now use LoadAnimImage and use the parameters to say you have 8 frames, and each are 32 pixels wide.

3) Make a variable in your program that says which frame the man is on i.e. start it at 0 and when it goes past 7 put it back to 0. Then when you draw your man with DrawImage, just show the correct frame. You will need a decent delay between each frame (i.e. when you add one to the variable mentioned earlier) or he will walk way too fast.

Your man is a "sprite" this is an object that moves around and interacts with the game world. Other sprites are enemies and bullets etc. Background scenery is not a sprite unless it is a moving lift or something. There are no "Sprite" commands as such in Blitz, it is just a very old game programming term.

hope this helps


coach(Posted 2005) [#5]
So let me get this straight. I draw all the frames on one bitmap? Thanks for helping me.


WolRon(Posted 2005) [#6]
Note that the DrawImage command has a fourth parameter for setting the frame to draw.

DrawImage image, x,y [,frame]
Parameters:
image = variable image pointer previously designated
x = the 'x' location of the screen to display the graphic
y = the 'y' location of the screen to display the graphic
frame = the frame number of the AnimImage to display (optional: default is 0)



xlsior(Posted 2005) [#7]
So let me get this straight. I draw all the frames on one bitmap? Thanks for helping me.


That's by far the easiest, since it will allow you to change a single variable in the drawimage command to cycle through the steps of your animation.


Gregor(Posted 2006) [#8]
What is a good drawingprogram to merge drawings to 1 animation. I did not succeed with photoshop and other drawingprogram you can only 'stitch' but that won't work either because you lose a strip from your drawing?

Anybody can recommend a good and easy drawing prgram to merge discrete drawings to 1 animation?


Adam Novagen(Posted 2006) [#9]
Check the BlitzBasic.com Toolbox; there's an excellent program there called GraphicsGale, specifically geared towards creating "sprites." When you install GG, follow this procedure for each image, to put them into one.

1. Start a new image in GG, and set the width & height values to the dimensions you need.

2. Open the first image that you want to insert, but open it in Microsoft Paint (my recommendation.)

3. Press CTRL + A to select the entire image, then press CTRL + X to "cut" it out.

4. Return to GG, and press CTRL + V to paste the image.

For every additional frame, click "Add Frame" (second toolbar, far left) and repeat steps 2-4. Note that all frames must be the same size, if they're in a single image. Good luck!


Gregor(Posted 2006) [#10]
OK thanks for the program


iaqsuk(Posted 2012) [#11]
Hi all,
I understand the players animated sprites with frames, up,down,left,right keys- with 4-6 frames.

How do I create a animated sprite for my enemies, for ex. my enemies are spiders and my frames are 4 frames legs not moving to legs moving without having to have keys to move them? I know a animated .gif files doesn't work unless you have a loadGIF scirpt.


GfK(Posted 2012) [#12]
There are several key steps of which you should take note for future reference to facilitate you achieving the aforementioned, erm... mentioned thing.

First - and this is really important - don't, I repeat DO NOT dig up a five year old thread that has little to do with your question. Adhering to this step will save me the four minutes of my life I just wasted reading the first half dozen posts before realising the original question is half a decade old.

Second, use LoadAnimImage.


iaqsuk(Posted 2012) [#13]
Sorry, I figured it out anyways:

DrawImage(spider1,enemy\xpos,enemy\ypos,frame)
frame = frame + 1
If frame > 1 Then
frame = 0
ElseIf frame < 0 Then
frame = 1
EndIf
did the trick.


GfK(Posted 2012) [#14]
Do you only have two frames? If so, frame = 1 - frame will constantly switch between frame 0 and frame 1.


iaqsuk(Posted 2012) [#15]
ya, im making more frames, I was just struggling on how to animate it and saw a old post. I am making a 4 or 6 frame so it will look more realistic. However is there a way to slow the frame rate if i make more frame?, stupid? but beginner, lol


GfK(Posted 2012) [#16]
Use a float instead of an Int. I.e:

Local frame#

frame = frame + 0.1
If frame >= 5
  frame = frame - 5
EndIf



iaqsuk(Posted 2012) [#17]
Thanks GfK, will use that instead of integer. iaqsuk