diff --git a/src/basic.h b/src/basic.h index 70bba74..13ae597 100644 --- a/src/basic.h +++ b/src/basic.h @@ -11,7 +11,7 @@ #define GAME_SPECIAL_ITEMMIXED 10 #define GAME_SPECIAL_ITEMSTRIGGER 2 #define GAME_SPECIAL_ITEMSROW 2 -#define GAME_SPECIAL_ITEMSPUSH 2 +#define GAME_SPECIAL_ITEMSPUSH 50 #define GAME_SPECIAL_ITEMSKICK 0 #define GAME_SPECIAL_ITEMSLIQUID 0 #define GAME_SPECIAL_ITEMSDESTROY 0 diff --git a/src/bomb.c b/src/bomb.c index 816b1fa..a59f82f 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -4,17 +4,17 @@ #include "network.h" #include "gfx.h" #include "sound.h" - +#include void draw_bomb (_bomb * bomb) { SDL_Rect src, dest; - int x = bomb->pos.x >> 8, - y = bomb->pos.y >> 8; + int x = bomb->pos.x, + y = bomb->pos.y; - if (x < 0 || y < 0 || x >= bman.fieldsize.x || y >= bman.fieldsize.y) { + if (x < 0 || y < 0 || x>>8 >= bman.fieldsize.x || y>>8 >= bman.fieldsize.y) { d_fatal ("Draw Bomb out of range [%d,%d]\n", x, y); return; } @@ -34,12 +34,12 @@ draw_bomb (_bomb * bomb) dest.w = src.w = gfx.bomb.image->w; dest.h = src.h = gfx.block.y; - dest.x = gfx.offset.x + (x * gfx.block.x); - dest.y = gfx.offset.y + (y * gfx.block.y); + dest.x = gfx.offset.x + (x* gfx.block.x/0x100); + dest.y = gfx.offset.y + (y* gfx.block.y/0x100); src.x = 0; src.y = src.h * bomb->frame; - draw_stone (x, y); + draw_stone (x>>8, y>>8); SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest); gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); @@ -74,33 +74,71 @@ bomb_explode (int p, int b, int net) void bomb_move (_bomb * bomb) { - _point npos; - if (bomb->pos.x == bomb->moveto.x) { - if (bomb->pos.y == bomb->moveto.y) { - bomb->moves = 0; - return; - } - if (bomb->pos.y > bomb->moveto.y) { - npos.y = bomb->pos.y - bomb->moves; //move bomb up - npos.x = bomb->pos.x; - } - else { - npos.y = bomb->pos.y + bomb->moves; // move bomb down - npos.x = bomb->pos.x; + _point npos,fpos; + int dx = 0, + dy = 0; + float vec; + if (bomb->moveto.x < 0) { + switch (bomb->moveto.x) { + case -1: + case -2: + dx = -bomb->moves; //move bomb left + case -3: + case -4: + dx = bomb->moves; //move bomb right } } else { - if (bomb->pos.x > bomb->moveto.x) { - npos.x = bomb->pos.x - bomb->moves; //move bomb left - npos.y = bomb->pos.y; - } - else { - npos.x = bomb->pos.x + bomb->moves; // move bomb right - npos.y = bomb->pos.y; + dx = bomb->moveto.x - bomb->pos.x; //move bomb to field + } + if (bomb->moveto.y < 0) { + switch (bomb->moveto.y) { + case -1: + case -2: + dy = -bomb->moves; //move bomb up + case -3: + case -4: + dy = bomb->moves; //move bomb down } } + else { + dy = bomb->moveto.y - bomb->pos.y; //move bomb to field + } + d_printf("move bomb %d %d\n",dx,dy); + if (!dx && !dy) { // bomb has reached its final position + bomb->moves = 0; + return; + } + // calculate movement + if (abs(dx)>bomb->moves || abs(dy)>bomb->moves) { + vec=sqrt(dx*dx+dy*dy); + dx=dx*bomb->moves/vec; + dy=dy*bomb->moves/vec; + } + npos.x=bomb->pos.x+dx; + npos.y=bomb->pos.y+dy; + d_printf("move bomb %d %d\n",dx,dy); + // check if field is used + /* + if (!(dx && dy)) { + fpos.x=npos.x>>8; + fpos.y=npos.y>>8; + if (((npos.x & 0xff ) >0) && (dx>0)) fpos.x++; + if (((npos.y & 0xff ) >0) && (dy>0)) fpos.y++; + if (bman.bfield[fpos.x][fpos.y] || bman.field[fpos.x][fpos.y].type != FT_nothing) { + npos.x &= 0xff00; + npos.y &= 0xff00; + if (dx<0) npos.x+=0x100; + if (dy<0) npos.y+=0x100; + } + } + */ + bomb->pos.x=npos.x; + bomb->pos.y=npos.y; } + + int bomb_loop () { @@ -135,7 +173,7 @@ bomb_loop () } draw_bomb (bomb); } -// if (bomb->moves>0) bomb_move(bomb); + if (bomb->moves>0) bomb_move(bomb); b++; // Count ticking Bombs for Return value break; case BS_exploding: diff --git a/src/special.c b/src/special.c index f74144c..8e038fa 100644 --- a/src/special.c +++ b/src/special.c @@ -117,13 +117,16 @@ special_push (int p_nr) } x += dx; y += dy; + // check that player is beside a bomb if (!bman.bfield[x][y]) return; x1 = x + dx; y1 = y + dy; + // check the field behind the bomb if (bman.bfield[x1][y1] || bman.field[x1][y1].type != FT_nothing) return; get_bomb_on (x, y, bombs); + // move all bombs on that field (there should be only 1) for (i = 0; bombs[i].x != -1; i++) { b = &bman.players[bombs[i].x].bombs[bombs[i].y]; if (b->state != BS_exploding) {