|
|
@ -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 */
|
|
|
|
/* field.c - procedures which are needed to control the field */
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
@ -7,6 +7,8 @@
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static _point fieldani[MAX_FILEDANIMATION];
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
draw_stone (int x, int y)
|
|
|
|
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 */
|
|
|
|
/* animate the stone if needed only for exploding stone */
|
|
|
|
if (stone->type == FT_stone && stone->frame > 0) {
|
|
|
|
if (stone->type == FT_stone && stone->frame > 0) {
|
|
|
|
|
|
|
|
field_animation_add (x, y);
|
|
|
|
if (stone->frameto == 0)
|
|
|
|
if (stone->frameto == 0)
|
|
|
|
if (stone->frame < gfx.field[stone->type].frames) {
|
|
|
|
if (stone->frame < gfx.field[stone->type].frames) {
|
|
|
|
stone->frame++;
|
|
|
|
stone->frame++;
|
|
|
@ -65,6 +68,8 @@ draw_stone (int x, int y)
|
|
|
|
|
|
|
|
|
|
|
|
/* some powerup so we need to animate this too */
|
|
|
|
/* some powerup so we need to animate this too */
|
|
|
|
else if (stone->type >= FT_death) {
|
|
|
|
else if (stone->type >= FT_death) {
|
|
|
|
|
|
|
|
field_animation_add (x, y);
|
|
|
|
|
|
|
|
|
|
|
|
if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) {
|
|
|
|
if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) {
|
|
|
|
stone->frameto = ANI_STONETIMEOUT;
|
|
|
|
stone->frameto = ANI_STONETIMEOUT;
|
|
|
|
stone->frame++;
|
|
|
|
stone->frame++;
|
|
|
@ -372,7 +377,6 @@ field_new (char *filename)
|
|
|
|
|
|
|
|
|
|
|
|
/* this is the item factor we multiply it with this so we know
|
|
|
|
/* this is the item factor we multiply it with this so we know
|
|
|
|
how much items we want in the game */
|
|
|
|
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 //
|
|
|
|
// Clean and create the field //
|
|
|
|
if (fmap == NULL) {
|
|
|
|
if (fmap == NULL) {
|
|
|
@ -434,3 +438,48 @@ field_new (char *filename)
|
|
|
|
/* put the kick special in the field */
|
|
|
|
/* put the kick special in the field */
|
|
|
|
field_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK);
|
|
|
|
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;
|
|
|
|
|
|
|
|
};
|
|
|
|