Hi again. In this document I'll research what the best possible solution is to make an animation 'player' for the game BattleCards.
After playing a card, you'll see a little animation of your character and your opponent what the effect of the played card is. This could be, for example, an animation of you shooting a fireball at your opponent or how you use heal to heal yourself.
Well. As you may know, BattleCards will feature different opponents, with each it's own animations. How many do we need? Let's see;
- Standing (0)
- Stricking/Attacking (1)
- Using magic (2) (opt)
- Getting attacked (3)
- Winning (4) (opt)
- Losing (5) (opt)
So in total at least 2 different animations for each character. The 2nd, 5th and 6th are optional. 0th is not an animation.
Next thing we need to determine is whether the animations sequences all have the same amount of frames or not. The answer is of course no. For example, the player's attacking animation will be longer than the slime ones. It can also be that some frames will be used more than once in a sequence (i.e.: frame 1, frame 2, frame 2, frame 3).
Last things, which is important, is whether the whole animation should move when animating or stand still and whether to loop it a certain times or not.
How to store all this? Well the best thing, which came into my mind is to store it like this:
.db AMMOUNT_OF_FRAMES, LOOP_AMMOUNT, X_INC/DEC, Y_INC/DEC, FRAME1, FRAME2, FRAME3, FRAME4, FRAME5
- Well, AMMOUNT_OF_FRAMES will tell how many frames there are, which is quite important for the routine which will execute the animation.
- LOOP_AMMOUNT will indicate how many loops to do. This have to be at least '1'.
- X_INC/DEC will indicate whether to increase or decrease X. 1=Increasing with 1, 2=Increasing with 2, 3=Decreasing with 1, 4=Decreasing with 2
- Y_INC/DEC does the same for Y.
- After that all frame positions are stored.
The animation routine will receive the number of the 'character' which will be animated (Player, Snake, Slime...) and the number of the action to perform.
Every character will have a list of adress where it stores it's list of animations.
.db H_Adress_of_Animations, L_Adress_of_Animations, ATTACKING, USING_MAGIC, GETTING_ATTACKED, WINNING,LOSING
If an (optional) animation has a 0 as value, it isn't avaible and the attacking animation will be played if called (which propably will not happen anyway).
When H_Adress_of_Animations,L_Adress_of_Animations adding to the startposition of all animations, you'll get the adress of the char animation.
A limitation of the approach as described above, is of course that all animations of a certain character may not have more than 255 including values for AMMOUNT_OF_FRAMES,LOOP_AMMOUNT,X_INC/DEC,Y_INC/DEC. So that's around max. 47 frames for every animation. Should be enough if you ask me.
So now we have all the data available we need. The routine will do the rest. Every frame (a preset value) it will display the next frame. If the LOOP_AMOUNT is set higher than 1, it will loop again. The animation routine will be called for both player and opponent. It is possible though to animate both at the same time. After playing the card a animation_loop routine will be called which will look like this:
Code: Select all
If Player or Opponent is not standing, than goto animation_loop
As said before the animation routine will than receive the 'character number' and the animation (Attacking, Using Magic, etc.) as input. It will delete the last frame from the buffer, plot the new one to it, and if the looped enough, it will set the inputed animation variable to 0.
The animations will have to be called from the cards, cause that's the point when it is decided which animation to be played. Of course first the values has to be set which animation to be set.
It als gives card developers the freedom to play an animation which most fits to their need.
As an bonus, there will be a custom animation, so that card developers can use that to make their own custom animation and play it. With that special effects can be used without programming this hard coded. (I know, I am to nice for this world =P). The custom animation has smaller limit than the premade ones; 25 frames can be used. The custom animation will be propably located in the saferam+1 and can be loaded with simple command ld (Custom_Animation_*Variablename*),a. (*Variablename* is in this instance of course the variable you want to load. i.e. AMMOUNT_OF_FRAMES).