|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: field.c,v 1.25 2003/06/02 21:21:17 stpohle Exp $ */
|
|
|
|
|
/* $Id: field.c,v 1.26 2003/06/02 23:32:36 stpohle Exp $ */
|
|
|
|
|
/* field.c - procedures which are needed to control the field */
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -40,9 +40,9 @@ draw_stone (int x, int y)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stone->type == FT_mixed) {
|
|
|
|
|
i = 0;
|
|
|
|
|
while (i < FT_death || i == FT_mixed || i >= FT_max)
|
|
|
|
|
i = s_random (FT_max - FT_death) + FT_death;
|
|
|
|
|
i = stone->mixframe;
|
|
|
|
|
if (i < FT_death || i >= FT_mixed)
|
|
|
|
|
i = FT_death;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
i = stone->type;
|
|
|
|
@ -69,18 +69,15 @@ draw_stone (int x, int y)
|
|
|
|
|
/* some powerup so we need to animate this too */
|
|
|
|
|
if (i == FT_death)
|
|
|
|
|
d = PWUP_bad;
|
|
|
|
|
else if (i > FT_death && i < FT_sp_trigger)
|
|
|
|
|
else
|
|
|
|
|
d = PWUP_good;
|
|
|
|
|
else
|
|
|
|
|
d = PWUP_special;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i >= FT_death) {
|
|
|
|
|
field_animation_add (x, y);
|
|
|
|
|
srcimg = gfx.powerup[d].image;
|
|
|
|
|
if (stone->frame >= gfx.powerup[d].frames)
|
|
|
|
|
if ((stone->frame & 0xFF) >= gfx.powerup[d].frames)
|
|
|
|
|
stone->frame = 0;
|
|
|
|
|
src.y = stone->frame * gfx.block.y;
|
|
|
|
|
src.y = (stone->frame & 0xFF) * gfx.block.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (srcimg != NULL)
|
|
|
|
@ -446,41 +443,48 @@ void
|
|
|
|
|
field_animation ()
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
|
|
_field *stone;
|
|
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
stone = &bman.field[fieldani[i].x][fieldani[i].y];
|
|
|
|
|
|
|
|
|
|
if ((stone->type == FT_stone && stone->frame > 0) || (stone->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 (stone->type == FT_stone) {
|
|
|
|
|
if (stone->frameto == 0)
|
|
|
|
|
if (stone->frame < gfx.field[FT_stone].frames) {
|
|
|
|
|
stone->frame++;
|
|
|
|
|
stone->frameto = ANI_STONETIMEOUT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bman.field[fieldani[i].x][fieldani[i].y].frameto > 0)
|
|
|
|
|
bman.field[fieldani[i].x][fieldani[i].y].frameto--;
|
|
|
|
|
if (stone->frameto > 0)
|
|
|
|
|
stone->frameto--;
|
|
|
|
|
}
|
|
|
|
|
else { /* animation is a powerup */
|
|
|
|
|
/* select right powerup animation */
|
|
|
|
|
if (bman.field[fieldani[i].x][fieldani[i].y].type == FT_death)
|
|
|
|
|
if (stone->type == FT_death)
|
|
|
|
|
j = PWUP_bad;
|
|
|
|
|
else if (bman.field[fieldani[i].x][fieldani[i].y].type > FT_sp_trigger)
|
|
|
|
|
else if (stone->type > FT_sp_trigger)
|
|
|
|
|
j = PWUP_special;
|
|
|
|
|
else
|
|
|
|
|
j = PWUP_good;
|
|
|
|
|
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++;
|
|
|
|
|
|
|
|
|
|
/* do the animation of the FT_mixed */
|
|
|
|
|
if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) {
|
|
|
|
|
stone->frameto = ANI_STONETIMEOUT;
|
|
|
|
|
stone->frame++;
|
|
|
|
|
if (stone->type == FT_mixed) {
|
|
|
|
|
stone->mixframe++;
|
|
|
|
|
if (stone->mixframe < FT_death || stone->mixframe >= FT_mixed)
|
|
|
|
|
stone->mixframe = FT_death;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bman.field[fieldani[i].x][fieldani[i].y].frame >= gfx.powerup[j].frames)
|
|
|
|
|
bman.field[fieldani[i].x][fieldani[i].y].frame = 0;
|
|
|
|
|
|
|
|
|
|
if (stone->frame >= gfx.powerup[j].frames)
|
|
|
|
|
stone->frame = 0;
|
|
|
|
|
}
|
|
|
|
|
draw_stone (fieldani[i].x, fieldani[i].y);
|
|
|
|
|
field_update (fieldani[i].x, fieldani[i].y);
|
|
|
|
|