Animation sprite

Started by
0 comments, last by pizzafan 19 years, 7 months ago
Hi, I wanted to know how to create the animation sprite in the bomberman game. the problem is when the bomberman drop the bomb it will come out the bomb effect. i wanted to know how to crete the effect into four direction, two direction? Pls show me the coding for how to create it. Thank u
Advertisement
ok, i suppose your game world is made of 2d tiles.

here is how i'd do, but of course, there may be some better ways to achieve this...

in this case you need only to draw 3 sprites for explosions :
(sorry for the ugly ascii art)
1. "horizontal" explosion (like uhm... that : "=" with a fire color, ared/yellow/white gradient for example)
2. "vertical" explosion (let's say : "||")
3. "cross" explosion (err... like that : "+")

then, i suggest you create a boolean array of the size of your tilemap (ie. if you have 10x10 tiles, you need a 10x10 array of booleans). initialize it with a "FALSE" value.

now, in your game loop :

when a bomb explodes, you recursively look at the four adjacent edges (north/south/east/west of the tile where the bomb is), and put a "TRUE" value in the boolean array, to tell later if a tile is "in fire".

then, after you're done with it, parse the boolean array and draw the appropriate sprite ("horizontal", "vertical" or "cross"), knowing it from the adjacent tiles (for example : "if (boolarray[x,y] AND boolarray[x+1,y] AND boolarray[x,y+1]) then drawsprite("cross");").

(err... i hope i'm clear enough for you to understand... feel free to ask more questions if something seems weird to you)

you can also make it easier by just using the "cross" sprite everywhere there's a "tile in fire".

btw, don't forget that :
- in a bomberman clone, the length of explosions vary
- you will need a counter to make the tiles "in fire" during a short moment, and then put the tiles back to normal.

i hope it will help you.

This topic is closed to new replies.

Advertisement