Animation = vitality; wakefulness; creation of cartoons.
The easiest way to make our RPG come alive is making animation. animation is possible by using more than one image. let's say i wanted to animate fire, i need to create 4 sprites - each one shows a different state of the burn.
This is how i do it: first, let's look at the Tile-Type we need to create
Type TileType
movement as integer 'tile movable/not-movable
nextframe 'for animation
End Type
Simple:
movement can be 0 or 1. 0 means not movable, 1 means movable.
nextframe can be 0-100000. 0 means no animation, if there's a number here then this is the next one to show
So if i had 3 fire sprites, let's say they are the 3, 4 and 5 on our sprite list:
Sprite 1 - Grass
Sprite 2 - Water
Sprite 3 - Fire A
Sprite 4 - Fire B
Sprite 5 - Fire C
Sprite 6 - House
Sprite 7 - Wall
so i make an array of tile-info:
Dim TileInfo(0 to 1000) as TileType
so this is how it looks now:
TileType(1).nextframe = 0 - (Grass: no animation)
TileType(2).nextframe = 0 - (Water: no animation)
TileType(3).nextframe = 4 - (Fire A: next frame will be the 4th)
TileType(4).nextframe = 5 - (Fire A: next frame will be the 5th)
TileType(5).nextframe = 4 - (Fire A: next frame will be the 3th - which is the first fire sprite)
TileType(6).nextframe = 0 - (House: no animation)
TileType(7).nextframe = 0 - (Wall: no animation)
So now we have the info about the tiles - now, let's see how it works in QB:
Do
'main loop
DrawMap
'draw the screen
Call Animate( )
this calls the Animate sub - you can use the FPS to make the animation faster/slower (by not calling it on every loop)
Loop
Sub Animate( )
'This sub will replace all tiles that should be replaced
For Y=1 to MapsizeY 'go through
For X=1 to MapsizeX 'all the map tiles
TempFrame = TileType(MapInfo(X, Y)).nextframe
TempFrame will get the value of nextframe of the tile we are checking
If TempFrame > 0 then MapInfo(X, Y) = TempFrame
we check the TempFrame value:
0 - means that there is no animation - so we do nothing
other values - this tile needs to be changed to the value of TempFrame
Next X
Next Y
End Sub
thats about it for this ANIMATION quicky
Tal Bereznitskey