bomb moving routine changed

origin
stpohle 22 years ago
parent 237f1e5236
commit fc002a8d15

@ -1,4 +1,6 @@
$Id: TODO,v 1.20 2003/07/27 21:47:22 patty21 Exp $ $Id: TODO,v 1.21 2003/08/27 21:14:48 stpohle Exp $
- timer options, for how long the game will go.
- more specials (Kicking Bomb, Pushing Bomb Ver.2) - more specials (Kicking Bomb, Pushing Bomb Ver.2)
@ -21,3 +23,5 @@ $Id: TODO,v 1.20 2003/07/27 21:47:22 patty21 Exp $
- team mode - team mode
- we need some more sound for picking up items. - we need some more sound for picking up items.
- ranking system, done by the bomberclonemserv

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.48 2003/08/24 19:01:30 stpohle Exp $ */ /* $Id: basic.h,v 1.49 2003/08/27 21:14:50 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -187,6 +187,14 @@ enum _bombstate {
}; };
enum _bombmode {
BM_normal = 0,
BM_pushed,
BM_moving,
BM_kicked
};
enum _playerstateflags { enum _playerstateflags {
PSF_used = 1, // Player Unused | Player Used PSF_used = 1, // Player Unused | Player Used
PSF_net = 2, // Local Player | AI / Network Player PSF_net = 2, // Local Player | AI / Network Player

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.40 2003/08/25 15:07:25 stpohle Exp $ */ /* $Id: bomb.c,v 1.41 2003/08/27 21:14:50 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -36,7 +36,7 @@ draw_bomb (_bomb * bomb)
src.x = 0; src.x = 0;
src.y = src.h * bomb->frame; src.y = src.h * bomb->frame;
stonelist_add (x>>8, y>>8); stonelist_add (x>>8, y>>8);
if (bomb->moves) { if (bomb->mode != BM_normal) {
stonelist_add ((x>>8)+1, y>>8); stonelist_add ((x>>8)+1, y>>8);
stonelist_add (x>>8, (y>>8)+1); stonelist_add (x>>8, (y>>8)+1);
stonelist_add ((x>>8)+1, (y>>8)+1); stonelist_add ((x>>8)+1, (y>>8)+1);
@ -73,74 +73,58 @@ bomb_explode (int p, int b, int net)
}; };
/* moves the bomb with it's speed,
dest.x|y = dx, dy of the current move */
void void
bomb_move (_bomb * bomb) bomb_move (_bomb * bomb)
{ {
_point npos; int step = 0, dist = 0, keepdir = 0;
int dx = 0, _point fpos, rpos;
dy = 0;
float vec; /* do this once, and again if the direction is still ok */
do {
if (bomb->moveto.x < 0) { /* get the current position of the bomb */
switch (bomb->moveto.x) { fpos.x = bomb->pos.x >> 8;
case -1: fpos.y = bomb->pos.y >> 8;
case -2: rpos.x = bomb->pos.x & 0xFF;
dx = -bomb->moves; //move bomb left rpos.y = bomb->pos.y & 0xFF;
case -3:
case -4: /* calculate the next step speed or next full field..
dx = bomb->moves; //move bomb right depend on what is the smaler one */
} if (bomb->dest.x < 0)
} step = rpos.x;
else { else if (bomb->dest.x > 0)
dx = bomb->moveto.x - bomb->pos.x; //move bomb to field step = 0x100 - rpos.x;
} else if (bomb->dest.y < 0)
if (bomb->moveto.y < 0) { step = rpos.y;
switch (bomb->moveto.y) { else if (bomb->dest.y > 0)
case -1: step = 0x100 - rpos.y;
case -2:
dy = -bomb->moves; //move bomb up if (step > bomb->speed || step == 0)
case -3: step = bomb->speed;
case -4:
dy = bomb->moves; //move bomb down /* move the bomb to the new position */
} if (bomb->dest.x < 0)
} bomb->pos.x -= step;
else { else if (bomb->dest.x > 0)
dy = bomb->moveto.y - bomb->pos.y; //move bomb to field bomb->pos.x += step;
} else if (bomb->dest.y < 0)
bomb->pos.y -= step;
if (!dx && !dy) { // bomb has reached its final position else if (bomb->dest.y > 0)
bomb->moves = 0; bomb->pos.y += step;
return;
} /* if we are on a complete field, check if we
can move to the next one */
// calculate movement if (((bomb->pos.x & 0xFF) == 0) && ((bomb->pos.y & 0xFF) == 0)) {
if (abs(dx)>bomb->moves || abs(dy)>bomb->moves) { if (bomb->mode == BM_pushed)
vec=sqrt(dx*dx+dy*dy); bomb->mode = BM_normal;
dx=dx*bomb->moves/vec; else if (bomb->mode == BM_moving) {
dy=dy*bomb->moves/vec; keepdir = 0;
}
npos.x=bomb->pos.x+dx;
npos.y=bomb->pos.y+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;
}
} while (dist < bomb->speed && bomb->mode == BM_moving && keepdir);
}
int int
@ -177,9 +161,13 @@ bomb_loop ()
} }
draw_bomb (bomb); draw_bomb (bomb);
} }
if (bomb->moves > 0 && bomb->state != BS_exploding) bomb_move(bomb);
if (bomb->mode != BM_normal)
bomb_action (bomb);
b++; // Count ticking Bombs for Return value b++; // Count ticking Bombs for Return value
break; break;
case BS_exploding: case BS_exploding:
if (bomb->to > 0) { if (bomb->to > 0) {
do_explosion (p, i); do_explosion (p, i);
@ -493,3 +481,16 @@ do_explosion (int p, int b)
if (bomb->state == BS_exploding) if (bomb->state == BS_exploding)
draw_explosion (bomb); draw_explosion (bomb);
}; };
inline void bomb_action (_bomb *bomb) {
switch (bomb->mode) {
case (BM_moving):
case (BM_pushed):
bomb_move (bomb);
break;
default:
bomb->mode = BM_normal;
break;
}
};

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.51 2003/08/10 21:10:07 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.52 2003/08/27 21:14:50 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -62,10 +62,11 @@ struct __bomb {
int frame; // frame of the animation int frame; // frame of the animation
int frameto; // timeout for the frame int frameto; // timeout for the frame
unsigned char r; // range of the bomb unsigned char r; // range of the bomb
unsigned char state; // state of the bomb unsigned char state; // state of the bomb BS_*
unsigned char mode; // mode of the bomb BM_*
int ex_nr; // explosion number int ex_nr; // explosion number
_point moveto; // destination to move the bomb to _point dest; // destination to move the bomb to
int moves; // bomb moving speed int speed; // bomb moving speed
} typedef _bomb; } typedef _bomb;
@ -222,12 +223,14 @@ extern inline int postofield (int pos);
// for the bomb.. // for the bomb..
extern int bomb_loop (); extern int bomb_loop ();
extern void bomb_explode (int p, int b, int net);
extern inline void bomb_action (_bomb *bomb);
extern void bomb_move (_bomb *bomb);
extern void get_bomb_on (short int x, short int y, _point bombs[]); extern void get_bomb_on (short int x, short int y, _point bombs[]);
extern void draw_fire (int x, int y, int d, int frame); extern void draw_fire (int x, int y, int d, int frame);
extern void do_explosion (int p, int b); extern void do_explosion (int p, int b);
extern void restore_explosion (_bomb * bomb); extern void restore_explosion (_bomb * bomb);
extern int explosion_check_field (int x, int y, int p, int b); extern int explosion_check_field (int x, int y, int p, int b);
extern void bomb_explode (int p, int b, int net);
// menus // menus
extern void draw_select (int select, _menu menu[], int x, int y); extern void draw_select (int select, _menu menu[], int x, int y);

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.44 2003/08/10 21:10:07 stpohle Exp $ */ /* $Id: field.c,v 1.45 2003/08/27 21:14:50 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */ /* field.c - procedures which are needed to control the field */
#include "bomberclone.h" #include "bomberclone.h"
@ -398,7 +398,7 @@ field_hurrydropitems ()
} }
if (try) { if (try) {
map.field[x][y].type = s_random (FT_mixed - 2) + 3; map.field[x][y].type = s_random (FT_mixed - FT_tunnel) + FT_tunnel+1;
stonelist_add (x, y); stonelist_add (x, y);
if (GT_MP_PTPM) if (GT_MP_PTPM)

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.51 2003/07/29 23:20:14 stpohle Exp $ /* $Id: game.c,v 1.52 2003/08/27 21:14:50 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -283,7 +283,55 @@ game_end ()
void void
game_start () game_start ()
{ {
int p, i;
menu_displaytext ("Loading..", "Please Wait", 32, 128, 32); menu_displaytext ("Loading..", "Please Wait", 32, 128, 32);
for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
if (bman.players[p].gfx_nr == -1) {
bman.players[p].gfx = NULL;
bman.players[p].state &= (0xff - (PSF_alife + PSF_playing));
}
else {
bman.players[p].state |= PSF_alife + PSF_playing;
bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr];
}
}
else
bman.players[p].state = 0;
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
bman.players[p].special.type = SP_nothing;
bman.players[p].m = 0;
bman.players[p].old.x = 0;
bman.players[p].old.y = 0;
bman.updatestatusbar=1;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
bman.players[p].pos.x = -1;
bman.players[p].pos.y = -1;
bman.players[p].tunnelto = 0;
/* all types of illnes turn them off */
for (i = 0; i < PI_max; i++)
bman.players[p].ill[i].to = 0;
// reset bombs
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
bman.players[p].bombs[i].speed = 0;
bman.players[p].bombs[i].dest.x = 0;
bman.players[p].bombs[i].dest.y = 0;
bman.players[p].bombs[i].mode = BM_normal;
}
}
tileset_load (map.tileset); tileset_load (map.tileset);
gfx_load_players (gfx.block.x, gfx.block.y); gfx_load_players (gfx.block.x, gfx.block.y);
snd_load (map.tileset); snd_load (map.tileset);

@ -232,9 +232,9 @@ host_multiplayer_game ()
if (bman.p_nr != -1) { if (bman.p_nr != -1) {
bman.state = GS_update; bman.state = GS_update;
net_new_game (); net_new_game ();
init_map_tileset();
net_send_servermode (); net_send_servermode ();
game_start (); game_start ();
init_map_tileset();
net_transmit_gamedata (); net_transmit_gamedata ();
if (bman.state == GS_ready || bman.state == GS_running) { if (bman.state == GS_ready || bman.state == GS_running) {

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.40 2003/08/24 19:52:08 stpohle Exp $ */ /* $Id: network.c,v 1.41 2003/08/27 21:14:50 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
@ -768,57 +768,16 @@ net_game_send_ill (int p_nr)
void void
net_new_game () net_new_game ()
{ {
int p, int p;
i;
// reset playerposition
for (i = 0; i < MAX_PLAYERS; i++)
bman.players[i].pos.y = bman.players[i].pos.x = -1;
/* set all multiplayer depending datas */
bman.players_nr = 0; bman.players_nr = 0;
bman.players_nr_s = 0; bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].frame = 0; if (PS_IS_used (bman.players[p].state))
bman.players[p].frameto = 0;
bman.players[p].tunnelto = -1;
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++; bman.players_nr_s++;
if (bman.players[p].gfx_nr == -1) {
bman.players[p].gfx = NULL;
bman.players[p].state &= (0xff - (PSF_alife + PSF_playing));
}
else {
bman.players[p].state |= PSF_alife + PSF_playing;
bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr];
}
}
else else
bman.players[p].state = 0; bman.players[p].state = 0;
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
bman.players[p].m = 0;
bman.players[p].old.x = 0;
bman.players[p].old.y = 0;
bman.players[p].special.type = SP_nothing;
bman.updatestatusbar=1;
for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
// reset bombs
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
bman.players[p].bombs[i].moves = 0;
bman.players[p].bombs[i].moveto.x = 0;
bman.players[p].bombs[i].moveto.y = 0;
}
} }
bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player

@ -612,7 +612,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n"); d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n");
if ((bomb->state == BS_ticking || bomb->state == BS_trigger) && (b_dat->state == BS_ticking || b_dat->state == BS_trigger)) { // handle push & kick special if ((bomb->state == BS_ticking || bomb->state == BS_trigger) && (b_dat->state == BS_ticking || b_dat->state == BS_trigger)) { // handle push & kick special
if (bomb->moves) if (bomb->mode != BM_normal)
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location
else else
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 1; //set bomb at position map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 1; //set bomb at position
@ -634,10 +634,11 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
bomb->r = b_dat->r; bomb->r = b_dat->r;
bomb->ex_nr = b_dat->ex_nr; bomb->ex_nr = b_dat->ex_nr;
bomb->state = b_dat->state; bomb->state = b_dat->state & 0x0F;
bomb->moves = b_dat->moves; bomb->mode = b_dat->state >> 4;
bomb->moveto.x = b_dat->movetox; bomb->speed = b_dat->speed;
bomb->moveto.y = b_dat->movetoy; bomb->dest.x = b_dat->destx;
bomb->dest.y = b_dat->desty;
if (bomb->state == BS_exploding) if (bomb->state == BS_exploding)
bomb_explode (b_dat->p_nr, b_dat->b_nr, 0); bomb_explode (b_dat->p_nr, b_dat->b_nr, 0);
@ -659,13 +660,13 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
b_dat.to = bomb->to; b_dat.to = bomb->to;
b_dat.r = bomb->r; b_dat.r = bomb->r;
b_dat.ex_nr = bomb->ex_nr; b_dat.ex_nr = bomb->ex_nr;
b_dat.state = bomb->state; b_dat.state = (bomb->mode << 4) | (bomb->state);
b_dat.b_nr = b; b_dat.b_nr = b;
b_dat.p_nr = p; b_dat.p_nr = p;
b_dat.h.flags = PKGF_ackreq; b_dat.h.flags = PKGF_ackreq;
b_dat.moves = bomb->moves; b_dat.speed = bomb->speed;
b_dat.movetox = bomb->moveto.x; b_dat.destx = bomb->dest.x;
b_dat.movetoy = bomb->moveto.y; b_dat.desty = bomb->dest.y;
send_pkg ((struct pkg *) &b_dat, addr); send_pkg ((struct pkg *) &b_dat, addr);
}; };

@ -159,9 +159,9 @@ struct pkg_bombdata {
unsigned char r; unsigned char r;
int ex_nr; int ex_nr;
int to; int to;
unsigned short int movetox; unsigned short int destx;
unsigned short int movetoy; unsigned short int desty;
signed short int moves; signed short int speed;
}; };

@ -492,6 +492,7 @@ player_drop_bomb (int pl_nr)
bomb->state = BS_ticking; bomb->state = BS_ticking;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
} }
bomb->mode = BM_normal;
bomb->ex_nr = -1; bomb->ex_nr = -1;
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1;
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.43 2003/08/10 19:31:15 stpohle Exp $ */ /* $Id: single.c,v 1.44 2003/08/27 21:14:50 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -7,52 +7,26 @@
void void
single_game_new () single_game_new ()
{ {
int p, int p;
i;
bman.players_nr_s = 1; bman.players_nr_s = 1;
bman.players_nr = 1; bman.players_nr = 1;
// set players variables // set players variables, only the variables which depend on single games
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = -1;
bman.players[p].pos.y = -1;
if (PS_IS_used (bman.players[p].state)) { if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++; bman.players_nr_s++;
bman.players_nr++; bman.players_nr++;
bman.players[p].tunnelto = 0;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing; bman.players[p].state = PSF_used + PSF_alife + PSF_playing;
} }
else else
bman.players[p].state = 0; bman.players[p].state = 0;
// reset bombs
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
bman.players[p].special.type = SP_nothing;
bman.updatestatusbar = 1;
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
bman.players[p].bombs[i].moves = 0;
bman.players[p].bombs[i].moveto.x = 0;
bman.players[p].bombs[i].moveto.y = 0;
}
for (i = 0; i < PI_max; i++)
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
} }
bman.players[bman.p_nr].state = PSFM_alife; bman.players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], bman.players[bman.p_nr].gfx_nr); player_set_gfx (&bman.players[bman.p_nr], bman.players[bman.p_nr].gfx_nr);
bman.last_ex_nr = 1; bman.last_ex_nr = 1;
init_map_tileset ();
bman.gametype = GT_single; bman.gametype = GT_single;
bman.state = GS_running; bman.state = GS_running;
}; };
@ -632,8 +606,9 @@ single_playergame ()
bman.state = GS_ready; bman.state = GS_ready;
while (!done && bman.state != GS_quit && bman.state != GS_startup) { while (!done && bman.state != GS_quit && bman.state != GS_startup) {
single_game_new ();
game_start (); game_start ();
single_game_new ();
init_map_tileset ();
game_loop (); game_loop ();
game_end (); game_end ();
} }

@ -1,4 +1,4 @@
/* $Id: special.c,v 1.24 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: special.c,v 1.25 2003/08/27 21:14:50 stpohle Exp $ */
/* special.c - procedues to control the specials */ /* special.c - procedues to control the specials */
#include "bomberclone.h" #include "bomberclone.h"
@ -87,6 +87,7 @@ special_row (int p_nr)
} }
} }
void void
special_push (int p_nr) special_push (int p_nr)
{ {
@ -130,7 +131,7 @@ special_push (int p_nr)
y1 = y + dy; y1 = y + dy;
// check the field behind the bomb // check the field behind the bomb
if (map.bfield[x1][y1] || map.field[x1][y1].type != FT_nothing) if (map.bfield[x1][y1] || (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel))
return; return;
get_bomb_on (x << 8, y << 8, bombs); get_bomb_on (x << 8, y << 8, bombs);
@ -138,9 +139,10 @@ special_push (int p_nr)
for (i = 0; bombs[i].x != -1; i++) { for (i = 0; bombs[i].x != -1; i++) {
b = &bman.players[bombs[i].x].bombs[bombs[i].y]; b = &bman.players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) { if (b->state != BS_exploding) {
b->moveto.x = x1 << 8; b->dest.x = dx;
b->moveto.y = y1 << 8; b->dest.y = dy;
b->moves = p->speed; b->speed = p->speed;
b->mode = BM_pushed;
map.bfield[x][y] = 0; map.bfield[x][y] = 0;
map.bfield[x1][y1] = 1; map.bfield[x1][y1] = 1;
stonelist_add (x, y); stonelist_add (x, y);
@ -149,9 +151,9 @@ special_push (int p_nr)
} }
} }
} }
} }
void void
special_pickup (int p_nr, int s_nr) special_pickup (int p_nr, int s_nr)
{ {

Loading…
Cancel
Save