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)
@ -21,3 +23,5 @@ $Id: TODO,v 1.20 2003/07/27 21:47:22 patty21 Exp $
- team mode
- 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 */
#ifndef _BC_BASIC_H_
@ -187,6 +187,14 @@ enum _bombstate {
};
enum _bombmode {
BM_normal = 0,
BM_pushed,
BM_moving,
BM_kicked
};
enum _playerstateflags {
PSF_used = 1, // Player Unused | Player Used
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 */
#include "bomberclone.h"
@ -36,7 +36,7 @@ draw_bomb (_bomb * bomb)
src.x = 0;
src.y = src.h * bomb->frame;
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, (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
bomb_move (_bomb * bomb)
{
_point npos;
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 {
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
}
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;
// 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;
}
int step = 0, dist = 0, keepdir = 0;
_point fpos, rpos;
/* do this once, and again if the direction is still ok */
do {
/* get the current position of the bomb */
fpos.x = bomb->pos.x >> 8;
fpos.y = bomb->pos.y >> 8;
rpos.x = bomb->pos.x & 0xFF;
rpos.y = bomb->pos.y & 0xFF;
/* calculate the next step speed or next full field..
depend on what is the smaler one */
if (bomb->dest.x < 0)
step = rpos.x;
else if (bomb->dest.x > 0)
step = 0x100 - rpos.x;
else if (bomb->dest.y < 0)
step = rpos.y;
else if (bomb->dest.y > 0)
step = 0x100 - rpos.y;
if (step > bomb->speed || step == 0)
step = bomb->speed;
/* move the bomb to the new position */
if (bomb->dest.x < 0)
bomb->pos.x -= step;
else if (bomb->dest.x > 0)
bomb->pos.x += step;
else if (bomb->dest.y < 0)
bomb->pos.y -= step;
else if (bomb->dest.y > 0)
bomb->pos.y += step;
/* if we are on a complete field, check if we
can move to the next one */
if (((bomb->pos.x & 0xFF) == 0) && ((bomb->pos.y & 0xFF) == 0)) {
if (bomb->mode == BM_pushed)
bomb->mode = BM_normal;
else if (bomb->mode == BM_moving) {
keepdir = 0;
}
*/
bomb->pos.x=npos.x;
bomb->pos.y=npos.y;
}
}
} while (dist < bomb->speed && bomb->mode == BM_moving && keepdir);
}
int
@ -177,9 +161,13 @@ bomb_loop ()
}
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
break;
case BS_exploding:
if (bomb->to > 0) {
do_explosion (p, i);
@ -493,3 +481,16 @@ do_explosion (int p, int b)
if (bomb->state == BS_exploding)
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 */
#ifndef _BOMBERCLONE_H_
@ -62,10 +62,11 @@ struct __bomb {
int frame; // frame of the animation
int frameto; // timeout for the frame
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
_point moveto; // destination to move the bomb to
int moves; // bomb moving speed
_point dest; // destination to move the bomb to
int speed; // bomb moving speed
} typedef _bomb;
@ -222,12 +223,14 @@ extern inline int postofield (int pos);
// for the bomb..
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 draw_fire (int x, int y, int d, int frame);
extern void do_explosion (int p, int b);
extern void restore_explosion (_bomb * bomb);
extern int explosion_check_field (int x, int y, int p, int b);
extern void bomb_explode (int p, int b, int net);
// menus
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 */
#include "bomberclone.h"
@ -398,7 +398,7 @@ field_hurrydropitems ()
}
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);
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. */
#include <string.h>
@ -283,7 +283,55 @@ game_end ()
void
game_start ()
{
int p, i;
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);
gfx_load_players (gfx.block.x, gfx.block.y);
snd_load (map.tileset);

@ -232,9 +232,9 @@ host_multiplayer_game ()
if (bman.p_nr != -1) {
bman.state = GS_update;
net_new_game ();
init_map_tileset();
net_send_servermode ();
game_start ();
init_map_tileset();
net_transmit_gamedata ();
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.
*/
@ -768,57 +768,16 @@ net_game_send_ill (int p_nr)
void
net_new_game ()
{
int p,
i;
// reset playerposition
for (i = 0; i < MAX_PLAYERS; i++)
bman.players[i].pos.y = bman.players[i].pos.x = -1;
int p;
/* set all multiplayer depending datas */
bman.players_nr = 0;
bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].tunnelto = -1;
if (PS_IS_used (bman.players[p].state)) {
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].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

@ -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");
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
else
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->ex_nr = b_dat->ex_nr;
bomb->state = b_dat->state;
bomb->moves = b_dat->moves;
bomb->moveto.x = b_dat->movetox;
bomb->moveto.y = b_dat->movetoy;
bomb->state = b_dat->state & 0x0F;
bomb->mode = b_dat->state >> 4;
bomb->speed = b_dat->speed;
bomb->dest.x = b_dat->destx;
bomb->dest.y = b_dat->desty;
if (bomb->state == BS_exploding)
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.r = bomb->r;
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.p_nr = p;
b_dat.h.flags = PKGF_ackreq;
b_dat.moves = bomb->moves;
b_dat.movetox = bomb->moveto.x;
b_dat.movetoy = bomb->moveto.y;
b_dat.speed = bomb->speed;
b_dat.destx = bomb->dest.x;
b_dat.desty = bomb->dest.y;
send_pkg ((struct pkg *) &b_dat, addr);
};

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

@ -492,6 +492,7 @@ player_drop_bomb (int pl_nr)
bomb->state = BS_ticking;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
}
bomb->mode = BM_normal;
bomb->ex_nr = -1;
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1;
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 */
#include "basic.h"
@ -7,52 +7,26 @@
void
single_game_new ()
{
int p,
i;
int p;
bman.players_nr_s = 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++) {
bman.players[p].pos.x = -1;
bman.players[p].pos.y = -1;
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
bman.players_nr++;
bman.players[p].tunnelto = 0;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing;
}
}
else
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;
player_set_gfx (&bman.players[bman.p_nr], bman.players[bman.p_nr].gfx_nr);
bman.last_ex_nr = 1;
init_map_tileset ();
bman.gametype = GT_single;
bman.state = GS_running;
};
@ -632,8 +606,9 @@ single_playergame ()
bman.state = GS_ready;
while (!done && bman.state != GS_quit && bman.state != GS_startup) {
single_game_new ();
game_start ();
single_game_new ();
init_map_tileset ();
game_loop ();
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 */
#include "bomberclone.h"
@ -87,6 +87,7 @@ special_row (int p_nr)
}
}
void
special_push (int p_nr)
{
@ -130,7 +131,7 @@ special_push (int p_nr)
y1 = y + dy;
// 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;
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++) {
b = &bman.players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) {
b->moveto.x = x1 << 8;
b->moveto.y = y1 << 8;
b->moves = p->speed;
b->dest.x = dx;
b->dest.y = dy;
b->speed = p->speed;
b->mode = BM_pushed;
map.bfield[x][y] = 0;
map.bfield[x1][y1] = 1;
stonelist_add (x, y);
@ -149,9 +151,9 @@ special_push (int p_nr)
}
}
}
}
void
special_pickup (int p_nr, int s_nr)
{

Loading…
Cancel
Save