diff --git a/include/basic.h b/include/basic.h index 7bd4f2b..c03bd2e 100644 --- a/include/basic.h +++ b/include/basic.h @@ -1,4 +1,4 @@ -/* $Id: basic.h,v 1.23 2004/05/20 16:55:30 stpohle Exp $ */ +/* $Id: basic.h,v 1.24 2004/08/30 20:01:29 stpohle Exp $ */ /* basic types which we need everywhere */ #ifndef _BC_BASIC_H_ @@ -21,6 +21,7 @@ #define HURRYWARN_TO_BLINKING 0.10 #define EXPLOSION_SAVE_DISTANCE 0.25 +#define EXPLOSION_GROW_SPEED 0.75f #define SPECIAL_TRIGGER_TIMEOUT 15 #define SPECIAL_TRIGGER_NUMUSE 5 // 0=unlimited #define SPECIAL_TRIGGER_TIME 25 diff --git a/include/bomb.h b/include/bomb.h index ce6aefa..675f6cf 100644 --- a/include/bomb.h +++ b/include/bomb.h @@ -1,4 +1,4 @@ -/* $Id: bomb.h,v 1.2 2004/08/08 23:18:46 stpohle Exp $ +/* $Id: bomb.h,v 1.3 2004/08/30 20:01:29 stpohle Exp $ * bomb include file */ @@ -29,7 +29,8 @@ struct { signed char p; // playernumber of this bomb signed char b; // bombnumber of this bomb } id; - int firer[4]; // range of the fire for the fire for each direction + float firer[4]; // range of the fire for the fire for each direction + int firemaxr [4]; // max range reached? float to; // timeout in ms after dropping the bomb. (loops * 0.0005sec) float frame; // frame of the animation unsigned char r; // range of the bomb diff --git a/src/bomb.c b/src/bomb.c index 86719e8..b2ccc25 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -1,4 +1,4 @@ -/* $Id: bomb.c,v 1.58 2004/08/08 23:18:46 stpohle Exp $ */ +/* $Id: bomb.c,v 1.59 2004/08/30 20:01:32 stpohle Exp $ */ /* everything what have to do with the bombs */ #include "bomberclone.h" @@ -103,14 +103,7 @@ draw_bomb (_bomb * bomb) void bomb_explode (_bomb *bomb, int net) { - int d, - ftype, - dx, - dy; - _point dir_ch [] ={ { -1, 0 }, - { 1, 0 }, - { 0, -1 }, - { 0, 1 } }; + int d; d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", bomb->id.p, bomb->id.b, bomb->pos.x, bomb->pos.y); @@ -120,23 +113,18 @@ bomb_explode (_bomb *bomb, int net) players[bomb->id.p].bomb_lastex = bomb->id.b; bomb->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */ bomb->state = BS_exploding; + + explosion_check_field ((int)bomb->pos.x, (int)bomb->pos.y, bomb); + for (d = 0; d < 4; d++) { - dx = bomb->pos.x; - dy = bomb->pos.y; - bomb->firer[d] = 0; - ftype = map.field[dx][dy].type; - - while ((ftype == FT_nothing || ftype == FT_tunnel) && bomb->firer[d] < bomb->r) { - bomb->firer[d]++; - dx += dir_ch[d].x; - dy += dir_ch[d].y; - ftype = explosion_check_field (dx, dy, bomb); - if (ftype == FT_nothing || ftype == FT_tunnel) { - map.field[dx][dy].ex[d].count++; - map.field[dx][dy].ex[d].frame = bomb->firer[d]; - stonelist_add (dx, dy); - } - } + bomb->firer[d] = 0.0f; + bomb->firemaxr[d] = 0; + map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].count++; + map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].frame = 0.0f; + map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex_nr = bomb->ex_nr; + map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].bomb_p = bomb->id.p; + map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].bomb_b = bomb->id.b; + stonelist_add ((int)bomb->pos.x, (int)bomb->pos.y); } if (GT_MP_PTPM && net) /* from now on only the server let the bomb explode */ @@ -360,6 +348,8 @@ void explosion_restore (_bomb *bomb) { { 0, -1 }, { 0, 1 } }; + // printf ("342: bomb (%d,%d)\n", (int) bomb->pos.x, (int) bomb->pos.y); + for (d = 0; d < 4; d++) { _x = bomb->pos.x; _y = bomb->pos.y; @@ -368,7 +358,8 @@ void explosion_restore (_bomb *bomb) { map.field[_x][_y].ex[d].count--; if (map.field[_x][_y].ex[d].count == 0) map.field[_x][_y].ex[d].frame = 0; // reset the framenumber - + if (d==3) stonelist_add (_x, _y); + /* with every field where was an fire on it decrease the ex[].count value * and force an drawing of this field */ for (i = 0; i < bomb->firer[d]; i++) { // lower the number of explosions @@ -379,7 +370,7 @@ void explosion_restore (_bomb *bomb) { map.field[_x][_y].ex[d].count--; if (map.field[_x][_y].ex[d].count == 0) map.field[_x][_y].ex[d].frame = 0; // reset the framenumber - + // printf ("361: d = %d, (%d,%d)\n", d, _x, _y); stonelist_add (_x, _y); } @@ -398,6 +389,7 @@ void explosion_restore (_bomb *bomb) { map.field[_x][_y].type = FT_nothing; d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, map.field[_x][_y].ex_nr); + // printf ("380: d = %d, (%d,%d)\n", d, _x, _y); stonelist_add (_x, _y); if (GT_MP_PTPM) /* send only if we are the master */ @@ -469,12 +461,60 @@ explosion_draw (_bomb * bomb) * calculate the explosion itself, * check the direction of the explosion and and and * - * + * as long as the explosion grows, make sure the explosion will reach it's 'maximum' + * (MAX_RANGE) end at 1.5 seconds. Make sure all explosion will have the same speed. + * range += (MAX_RANGE/1.0) * timediff; + * */ void explosion_do (_bomb *bomb) { - /* with a slow pc disable this --- maybe option over a config menu */ - if (bomb->state == BS_exploding) + _point dir_ch [] ={ { -1, 0 }, + { 1, 0 }, + { 0, -1 }, + { 0, 1 } }; + int d, dx, dy, ftype; + float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED; + float range; + + if (bomb->state == BS_exploding) { + for (d = 0; d < 4; d++) { + if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) { + + range = bomb->firer[d]; + bomb->firer[d] += range_grow; + if (bomb->firer[d] > bomb->r) bomb->firer[d] = bomb->r; + + dx = bomb->pos.x + (dir_ch[d].x * rintf (range)); + dy = bomb->pos.y + (dir_ch[d].y * rintf (range)); + + /* check all fields between [dx,dy] and [odx,ody] */ + while (bomb->firemaxr[d] == 0 && (rintf (range) < rintf (bomb->firer[d]))) { + + if (rintf (range) < rintf(bomb->firer[d])) { + range += 1.0f; + dx += dir_ch[d].x; + dy += dir_ch[d].y; + } + + ftype = explosion_check_field (dx, dy, bomb); + if (ftype == FT_nothing || ftype == FT_tunnel) { + // printf ("484: count++ d=%d (%d,%d) c_old: %d\n", d, dx, dy, map.field[dx][dy].ex[d].count); + map.field[dx][dy].ex[d].count++; + map.field[dx][dy].ex[d].frame = 0.0f; + map.field[dx][dy].ex_nr = bomb->ex_nr; + map.field[dx][dy].ex[d].bomb_p = bomb->id.p; + map.field[dx][dy].ex[d].bomb_b = bomb->id.b; + stonelist_add (dx, dy); + } + else { + bomb->firemaxr[d] = 1; + bomb->firer[d] = rintf (bomb->firer[d]); + } + } + } + + } explosion_draw (bomb); + } }; diff --git a/src/field.c b/src/field.c index 0cc2840..c4b3716 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.57 2004/08/08 23:18:46 stpohle Exp $ */ +/* $Id: field.c,v 1.58 2004/08/30 20:01:32 stpohle Exp $ */ /* field.c - procedures which are needed to control the field */ #include "bomberclone.h" @@ -185,10 +185,16 @@ draw_stone (int x, int y) stone_drawfire (x, y, -1); break; } +/* + if (debug) { + char txt[64]; + sprintf (txt, "%d,%d%d", map.field[x][y].ex[0].count, map.field[x][y].ex[0].bomb_p, map.field[x][y].ex[0].bomb_b); font_gfxdraw (dest.x, dest.y, txt, 0, COLOR_white, (y*256) + 10); + sprintf (txt, "%d,%d%d", map.field[x][y].ex[1].count, map.field[x][y].ex[1].bomb_p, map.field[x][y].ex[1].bomb_b); font_gfxdraw (dest.x, dest.y+10, txt, 0, COLOR_white, (y*256) + 10); + sprintf (txt, "%d,%d%d", map.field[x][y].ex[2].count, map.field[x][y].ex[2].bomb_p, map.field[x][y].ex[2].bomb_b); font_gfxdraw (dest.x, dest.y+20, txt, 0, COLOR_white, (y*256) + 10); + sprintf (txt, "%d,%d%d", map.field[x][y].ex[3].count, map.field[x][y].ex[3].bomb_p, map.field[x][y].ex[3].bomb_b); font_gfxdraw (dest.x, dest.y+30, txt, 0, COLOR_white, (y*256) + 10); -// if (debug) -// font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, COLOR_white, (y*256) + 10); - + } +*/ return; };