From d5d3eaeffc5520845bb71095f113e88b1e455bcf Mon Sep 17 00:00:00 2001 From: stpohle Date: Sun, 1 Jun 2003 22:57:09 +0000 Subject: [PATCH] powerups are animated --- src/basic.h | 3 ++- src/bomb.c | 8 +++---- src/bomberclone.h | 4 +++- src/field.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-- src/game.c | 1 + 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/basic.h b/src/basic.h index b8b2817..917341c 100644 --- a/src/basic.h +++ b/src/basic.h @@ -42,7 +42,8 @@ #define MAX_FIELDSIZE_Y 31 #define MIN_FIELDSIZE_X 15 #define MIN_FIELDSIZE_Y 9 - +#define MAX_FILEDANIMATION 2048 /* number of points on the field to be animated exploding + stoned or powerups*/ #define EXPLOSIONTIMEOUT 20 #define ANI_FIRETIMEOUT 2 diff --git a/src/bomb.c b/src/bomb.c index 4f0db35..78e166c 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -289,14 +289,14 @@ explosion_check_field (int x, int y, int p, int b) // let the stones right beside explode if (bman.field[x][y].type != FT_nothing - && bman.field[x][y].type != FT_block && bomb->ex_nr != bman.field[x][y].ex_nr) { + && bman.field[x][y].type != FT_block && bomb->ex_nr != bman.field[x][y].ex_nr) if (bman.field[x][y].frame == 0) { bman.field[x][y].frameto = ANI_STONETIMEOUT; bman.field[x][y].frame = 1; + + draw_stone (x, y); + field_update(x, y); } - draw_stone (x, y); - field_update(x,y); - } return bman.field[x][y].type; }; diff --git a/src/bomberclone.h b/src/bomberclone.h index ec53b5b..87b902a 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.33 2003/06/01 22:51:58 patty21 Exp $ */ +/* $Id: bomberclone.h,v 1.34 2003/06/01 22:57:10 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -198,6 +198,8 @@ extern void field_update(int x,int y); extern void field_new (char *filename); extern void field_set_playerposition (int usermap); extern void tileset_random (); +extern void field_animation_add (int x, int y); +extern void field_animation (); // everything what is declared in players.c extern int dead_playerani (); diff --git a/src/field.c b/src/field.c index ba5c1e7..1209b4c 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.22 2003/06/01 22:06:30 stpohle Exp $ */ +/* $Id: field.c,v 1.23 2003/06/01 22:57:10 stpohle Exp $ */ /* field.c - procedures which are needed to control the field */ #include @@ -7,6 +7,8 @@ #include "bomberclone.h" #include "gfx.h" +static _point fieldani[MAX_FILEDANIMATION]; + void draw_stone (int x, int y) { @@ -39,6 +41,7 @@ draw_stone (int x, int y) /* animate the stone if needed only for exploding stone */ if (stone->type == FT_stone && stone->frame > 0) { + field_animation_add (x, y); if (stone->frameto == 0) if (stone->frame < gfx.field[stone->type].frames) { stone->frame++; @@ -65,6 +68,8 @@ draw_stone (int x, int y) /* some powerup so we need to animate this too */ else if (stone->type >= FT_death) { + field_animation_add (x, y); + if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) { stone->frameto = ANI_STONETIMEOUT; stone->frame++; @@ -372,7 +377,6 @@ field_new (char *filename) /* this is the item factor we multiply it with this so we know how much items we want in the game */ -// fkt = ((float)(bman.fieldsize.x * bman.fieldsize.y))/(25.0 * 17.0); // Clean and create the field // if (fmap == NULL) { @@ -434,3 +438,48 @@ field_new (char *filename) /* put the kick special in the field */ field_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK); } + + +/* run this to every game cycle for the animations on the field */ +void field_animation () { + int i; + + for (i = 0; i < MAX_FILEDANIMATION; i++) + if (fieldani[i].x >= 0 && fieldani[i].x < bman.fieldsize.x && fieldani[i].y >= 0 && fieldani[i].y < bman.fieldsize.y) { + /* check if there is a need to animate this */ + if ((bman.field[fieldani[i].x][fieldani[i].y].type == FT_stone && bman.field[fieldani[i].x][fieldani[i].y].frame > 0) || + (bman.field[fieldani[i].x][fieldani[i].y].type >= FT_death)) { + /* animate this stone */ + draw_stone (fieldani[i].x, fieldani[i].y); + field_update (fieldani[i].x, fieldani[i].y); + } + else /* delete this entry */ + fieldani[i].y = fieldani[i].x = -1; + } + else /* delete this entry */ + fieldani[i].y = fieldani[i].x = -1; +}; + + +/* add a new field to the animation data */ +void field_animation_add (int x, int y) { + int i, j = -1, d = -1; + + for (i = 0; i < MAX_FILEDANIMATION; i++) { + if (fieldani[i].x == x && fieldani[i].y == y) + d = i; + if (fieldani[i].x == -1 || fieldani[i].y == -1) + j = i; + } + + if (j == -1) { /* nothing anymore free */ + d_printf ("field_animation_add: animation data line too full\n"); + return; + } + + if (d != -1) /* this stone is already in the list */ + return; + + fieldani[j].x = x; + fieldani[j].y = y; +}; diff --git a/src/game.c b/src/game.c index b958d8a..acb35da 100644 --- a/src/game.c +++ b/src/game.c @@ -214,6 +214,7 @@ game_loop () /* this will even set the variable "bman.player_nr" to let us know how much Players are still left */ bomb_loop (); + field_animation (); draw_players (); game_draw_info (); gfx_UpdateRects ();