From 52778acba8e488fdf5ee6118b54a3ddfc3a21a94 Mon Sep 17 00:00:00 2001 From: stpohle Date: Mon, 2 Jun 2003 23:32:35 +0000 Subject: [PATCH] Mixed Powerup animation changed --- src/bomberclone.h | 5 ++-- src/field.c | 64 +++++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/bomberclone.h b/src/bomberclone.h index 87b902a..5bd2dc6 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.34 2003/06/01 22:57:10 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.35 2003/06/02 23:32:35 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -113,7 +113,8 @@ struct __ex_field { struct __field { unsigned char type; - int frame; // frame (frame > 0 && FS_stone) + signed char mixframe; // data for the mixed frame + short int frame; // frame (frame > 0 && FS_stone) int frameto; // frame to unsigned char special; // to save special stones _ex_field ex[4]; // count up every explosion there is on this field for ever direction diff --git a/src/field.c b/src/field.c index 25ce22e..480bb6e 100644 --- a/src/field.c +++ b/src/field.c @@ -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 @@ -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);