From fdef75cc0234700ee32f85daa71c53f78585da90 Mon Sep 17 00:00:00 2001 From: patty21 Date: Wed, 4 Jun 2003 19:53:51 +0000 Subject: [PATCH] started to work on smooth bombmovement --- src/bomb.c | 26 ++++++++++++++++++++++++++ src/bomberclone.h | 5 ++++- src/special.c | 5 +++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/bomb.c b/src/bomb.c index fd440cc..ce3403f 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -65,6 +65,31 @@ 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; + } + } 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; + } + } +} + int bomb_loop () { @@ -99,6 +124,7 @@ bomb_loop () } draw_bomb (bomb); } +// if (bomb->moves>0) bomb_move(bomb); b++; // Count ticking Bombs for Return value break; case BS_exploding: diff --git a/src/bomberclone.h b/src/bomberclone.h index 5bd2dc6..d4a08e1 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.35 2003/06/02 23:32:35 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.36 2003/06/04 19:53:52 patty21 Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -60,6 +60,9 @@ struct __bomb { unsigned char r; // range of the bomb unsigned char state; // state of the bomb int ex_nr; // explosion number + _point moveto; // destination to move the bomb to + int moves; // bomb moving speed + } typedef _bomb; struct __special { diff --git a/src/special.c b/src/special.c index e807db7..f74144c 100644 --- a/src/special.c +++ b/src/special.c @@ -127,8 +127,9 @@ special_push (int p_nr) for (i = 0; bombs[i].x != -1; i++) { b = &bman.players[bombs[i].x].bombs[bombs[i].y]; if (b->state != BS_exploding) { - b->pos.x = x1<<8; - b->pos.y = y1<<8; + b->moveto.x = x1<<8; + b->moveto.y = y1<<8; + b->moves=p->speed; bman.bfield[x][y]=0; bman.bfield[x1][y1]=1; draw_stone(x,y);