powerup and stone explosion animation

origin
stpohle 23 years ago
parent d5d3eaeffc
commit e5b21677df

@ -50,7 +50,7 @@
#define ANI_BOMBTIMEOUT 1
#define ANI_PLAYERTIMEOUT 1
#define ANI_PLAYERILLTIMEOUT 1
#define ANI_STONETIMEOUT 10
#define ANI_STONETIMEOUT 5
#define TIME_FACTOR 50
#define BOMB_TIMEOUT 5

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.23 2003/06/01 22:57:10 stpohle Exp $ */
/* $Id: field.c,v 1.24 2003/06/01 23:08:34 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */
#include <stdlib.h>
@ -41,15 +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++;
stone->frameto = ANI_STONETIMEOUT;
}
if (stone->frameto > 0)
stone->frameto--;
field_animation_add (x, y);
if (stone->frame < gfx.field[FT_stone].frames) {
src.y = stone->frame * gfx.block.y;
@ -59,46 +51,38 @@ draw_stone (int x, int y)
src.y = 0;
srcimg = gfx.field[FT_nothing].image;
}
}
else if (stone->type == FT_stone || stone->type == FT_block) {
src.y = 0;
srcimg = gfx.field[stone->type].image;
}
/* 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++;
}
else if (stone->type == FT_stone || stone->type == FT_block) {
src.y = 0;
srcimg = gfx.field[stone->type].image;
}
if (stone->frame >= gfx.powerup.frames)
stone->frame = 0;
/* some powerup so we need to animate this too */
else if (stone->type >= FT_death) {
field_animation_add (x, y);
srcimg = gfx.powerup.image;
src.y = stone->frame * gfx.block.y;
}
srcimg = gfx.powerup.image;
src.y = stone->frame * gfx.block.y;
}
if (srcimg != NULL)
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
if (srcimg != NULL)
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
if (stone->type >= FT_death) { /* draw now the powerup itself */
srcimg = gfx.field[stone->type].image;
src.y = 0;
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
}
if (stone->type >= FT_death) { /* draw now the powerup itself */
srcimg = gfx.field[stone->type].image;
src.y = 0;
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
}
// draw explosions if there is any
for (d = 0, i = 0; d < 4; d++)
if (stone->ex[d].count > 0) {
i = 1; // mark that there is already an explosion
draw_fire (x, y, d, -1);
}
for (d = 0, i = 0; d < 4; d++)
if (stone->ex[d].count > 0) {
i = 1; // mark that there is already an explosion
draw_fire (x, y, d, -1);
}
return;
return;
};
@ -441,45 +425,73 @@ field_new (char *filename)
/* 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;
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 */
if (bman.field[fieldani[i].x][fieldani[i].y].type == FT_stone) {
if (bman.field[fieldani[i].x][fieldani[i].y].frameto == 0)
if (bman.field[fieldani[i].x][fieldani[i].y].frame < gfx.field[FT_stone].frames) {
bman.field[fieldani[i].x][fieldani[i].y].frame++;
bman.field[fieldani[i].x][fieldani[i].y].frameto = ANI_STONETIMEOUT;
}
if (bman.field[fieldani[i].x][fieldani[i].y].frameto > 0)
bman.field[fieldani[i].x][fieldani[i].y].frameto--;
}
else {
if (bman.field[fieldani[i].x][fieldani[i].y].frameto-- <= 0 || bman.field[fieldani[i].x][fieldani[i].y].frameto > ANI_STONETIMEOUT) {
bman.field[fieldani[i].x][fieldani[i].y].frameto = ANI_STONETIMEOUT;
bman.field[fieldani[i].x][fieldani[i].y].frame++;
}
if (bman.field[fieldani[i].x][fieldani[i].y].frame >= gfx.powerup.frames)
bman.field[fieldani[i].x][fieldani[i].y].frame = 0;
}
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;
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;
};

Loading…
Cancel
Save