powerups are animated

origin
stpohle 23 years ago
parent 41a18f490e
commit d5d3eaeffc

@ -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

@ -289,11 +289,11 @@ 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);
}

@ -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 ();

@ -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 <stdlib.h>
@ -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;
};

@ -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 ();

Loading…
Cancel
Save