Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Animated Sprites

Author
Message
PST
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 12th Apr 2004 19:10
I tried to make an animated sprite of an explosion...

But it won't play, neither give an error message...
Need some help please...
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 13th Apr 2004 14:27
I had animated sprite problems too. Ive abandoned them, and prefer to just have a variable called frame or something, that way you can feed your sprite any image, so its easier to have, for example, one explosion animation that is used by all the enemy spaceships. You would have to then write some arays or data statements to hold the anim frame numbers. Incidentally, this gives you more contrl over the timing of your anims, because you can replay frames in any order...

GIve me more power!
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 13th Apr 2004 14:30
I also abandoned automatic animated sprites I just couldn't get them to work - I'm with Code Stealer on this one and manually handle the frames.

I just load the bitmap with the animation, use a for..next loop with Get Image to extract the frames, and then manually assign them to the sprite as the game runs.

PST
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 13th Apr 2004 18:30
Hum... anyone else knows something?
Thanks for the help anyway =)
PST
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 13th Apr 2004 19:02
Seems strange, but seems to work...

Might help...
PST
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 13th Apr 2004 19:16
OOOk animated sprites suck, wen inside a if condition just play the first frame....bah....
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 13th Apr 2004 22:31
Hmm, I wonder as well if there are any good tricks for holding lists of frame numbers, and cycling through them easily.

Im making a top down turn based stratergy game, so I might have flags, fire and charachter animations running all at the same time. I wonder if anyone hads a good stratergy for dealing with anim lists all starting t different time...

GIve me more power!
LordoFire
21
Years of Service
User Offline
Joined: 14th Feb 2004
Location: United States
Posted: 14th Apr 2004 04:26
Animating sprites is actually quite easy, i just helped a person on this a while ago. You need to place all your frames on one sheet at equal distances from each other. Then load it on and do the following code...

hope that helps!

When it comes to programing, I'm on fire!
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 14th Apr 2004 08:31
That's the method I currrently use - it was the "Play Sprite" I was personally having problems with which I could never get to work properly.

Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 14th Apr 2004 11:25
Thats helpfull, but I wanted to try to get some help with understanding how DB reads numbers out of a list.

Lets use this example:

My wizard is in the center of the screen surrounded some goblins and undead. He cast the spell destroy undead. So I need to play the casting animation for the wizard, the spell effect anim, the death anims for the undead and a hit reaction anim for the goblins. The spell radiates out from the wizard in a wave, so his anim starts, then the spell effect, then the enemy anims start all at different times, as the wave reaches them. So , for instance the undead, they all play the same list of image numbers as their anim, but they need to be fed to the correct sprite at the correct time.

I was thinking it would be good to maybe link each anim to a centralised timer, or something like that. Im sure I can work somthing out, but I just wanted to glean some tips on the best way to proceed before I start...

GIve me more power!
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 14th Apr 2004 12:51 Edited at: 14th Apr 2004 14:24
I tend to use typed arrays for my sprites - one of the array elements is a timer for the animation - and the current frame - and then a seperate array holding frames or ranges of frames for each "type" of character the sprites represent - for example, I could have 10 monsters but they all use the same animation frames, but one player - so I would have two sets of animation in this case.

Example would be :



You could extend this further and have either a typed array for animation frames, or use #CONSTANTS to put labels on the frames or frame ranges :



e.t.c.

In the case of several sprites which have their own animation frames typed arrays could be useful :



I have used this technique in a game I am developing at the moment - basically I name all my animation frames and reference them by label name instead of having to remember numbers - the numbers are of course assigned to the frame names in a routine called early on in the game - it's no faster than knowing frames but it makes your programs a lot easier to maintain and if an animation sequence changes in number of frames you only need to change them once in the program instead of going through the program looking for the places where the frame numbers are used.

I am not sure whether this helps you or not - we all have our own way of writing programs.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Apr 2004 15:00
Quote: "My wizard is in the center of the screen surrounded some goblins and undead. He cast the spell destroy undead. So I need to play the casting animation for the wizard, the spell effect anim, the death anims for the undead and a hit reaction anim for the goblins. The spell radiates out from the wizard in a wave, so his anim starts, then the spell effect, then the enemy anims start all at different times, as the wave reaches them. So , for instance the undead, they all play the same list of image numbers as their anim, but they need to be fed to the correct sprite at the correct time.
"


The spell radiates out? There are two ways that you can interpret this. Either the spell animation actually travels accross the screen. Then you could use a distance formula to start the second animation. Or the spell animation stands still, in which case you could use one of its frame numbers to start the next animation.

Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 14th Apr 2004 16:18
Yes, I was more asking about a good way to feed the same list of frame numbers into the correct sprites, all starting at different times.

Lets say my zombie death anim is images 1,2,3,4,5. Now, zombie 1 is closest to the wizard, so the spell starts to effect him first. He plays frame 1. Then the next pass of the cycle, zombie2 is hit, so he plays frame 1, while zombie1 is on frame 2. Then 2 frames later zombie3 is hit, so plays frame 1, while zombie 2 is on frame 4 and zombie 1 is on frame 5. I want some help with methods for tracking which frame should be playing for each sprite. Should I use arrays, data statements or what?



for n=1 to amount of sprites

sprite n,x,y,frame(correctframe)

next n

GIve me more power!
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Apr 2004 16:24
Different staggered stages of animation can be handled with a DIM EnemyFrame(10).

EnemyFrame(1) = 5
EnemyFrame(2) = 2
Enemyframe(3) = 7

So Enemy 1 is on frame 5 of his animation.
Enemy 2 is on frame 2 of his animation
Enemy 3 is on frame 7 of his animation.

EnemyFrame(1) = EnemyFrame(1) + 1

Now enemy 1 is on frame 6 of his animation

If EnemyFrame(1) = 6 then EnemyFrame(1) = 1

Now enemy 1 has looped back to the beginning of his animation.

Morloc
21
Years of Service
User Offline
Joined: 21st Mar 2004
Location: UK
Posted: 14th Apr 2004 17:33
to just back pincho up as this is the way he explained to me. This Dim method works very well.

You can have as many enemies on screen at different points in their animation as you like.

you must put the code in a for next loop though and replace the eg dim(2) with say dim(n).

The good thing is that you have just one bit of code that handles any enemy. you do other dims though like enemy alive = (dead,alive, dying)

heres my enemy code if it helps.



hope that helps

Morloc
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 14th Apr 2004 17:55
Yes thanks that was very help full.

Ok I understood that little piece of code, but what can I do if I want to have frames that are not in sequence? For example, if I have a man with a hammer, and I want the extremes of the anim to hold for longer than the tweens, I might play the anim like this, where each number is an image number:

1,2,3,4,5,5,5,5,5,3,1,1,1,1

What is a good way to hold this sequence of numbers? Dimention an array to hold my frames? I suppose as they are being read in sequence then a data statent might work. The only trouble is, Im going to have about 400 possible deaths, hit reacts and attack anims( each charachter in game can do these actions, plus wizards casting spells and special anims). I guess if I make all the deaths the same number of frames I could use a 2d array?

dim deathanim(400,10)

then make sure all my death anims have 10 frames....

GIve me more power!
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Apr 2004 18:43 Edited at: 14th Apr 2004 18:45
1,2,3,4,5,5,5,5,5,3,1,1,1,1

or

1,100
2,100
3,100
4,100
5,500
3,100
1,400

Where the second version is used in DIM again.

Dim EnemyAnim(7,2)

enemyAnim(1,1) = 1
enemyAnim(1,2) = 100
enemyAnim(2,1) = 2
enemyAnim(2,2) = 100......etc


You could even make an animation editor, or converter to convert your first method into the second method.

Zone Chicken
21
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 18th Apr 2004 07:59 Edited at: 18th Apr 2004 08:01
Just started fooling around with animated sprites, and am loading a avi then playing it to a image, looping the animation, then making the image a sprite. but when i set the the sprite to 1,0,1 the sprite will not become transparent anyone know why this is?


Need it transparent if its going to overlap other object such as a explosion effect over a moutain terrain in a overhead view.
Triple Ha
21
Years of Service
User Offline
Joined: 18th Apr 2004
Location: California, but I wish I was in Japan
Posted: 18th Apr 2004 08:53 Edited at: 10th May 2004 05:33


If interested in making games go to http://www.freewebs.com/abutton/...NOW!

Login to post a reply

Server time is: 2025-05-14 03:52:34
Your offset time is: 2025-05-14 03:52:34