pushing and moving bombs and this is working now right.

origin
stpohle 22 years ago
parent 4ffbe4c045
commit e6c0221207

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.6 2003/11/08 06:27:58 stpohle Exp $ */ /* $Id: basic.h,v 1.7 2003/11/08 19:53:06 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -12,12 +12,11 @@
#define GAME_SPECIAL_ITEMMIXED 20 #define GAME_SPECIAL_ITEMMIXED 20
#define GAME_SPECIAL_ITEMSTRIGGER 3 #define GAME_SPECIAL_ITEMSTRIGGER 3
#define GAME_SPECIAL_ITEMSROW 3 #define GAME_SPECIAL_ITEMSROW 3
#define GAME_SPECIAL_ITEMSPUSH 2 #define GAME_SPECIAL_ITEMSPUSH 3
#define GAME_MAX_TUNNELS 4 // number of tunnel entrys #define GAME_MAX_TUNNELS 4 // number of tunnel entrys
#define GAME_TIMEOUT 30000 // game timeout 10min) #define GAME_TIMEOUT 30000 // game timeout 10min)
#define GAME_TIMEOUTHURRY 3000 // game timeout for hurry and dropping mode (1min) #define GAME_TIMEOUTHURRY 3000 // game timeout for hurry and dropping mode (1min)
#define GAME_TUNNEL_TO 50 /* wait 5 game cycls before move and show #define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds
player again */
#define EXPLOSION_SAVE_DISTANCE 0.25 #define EXPLOSION_SAVE_DISTANCE 0.25
#define SPECIAL_TRIGGER_TIMEOUT 15 #define SPECIAL_TRIGGER_TIMEOUT 15
@ -28,13 +27,13 @@
#define START_BOMBS 1 #define START_BOMBS 1
#define START_RANGE 2 #define START_RANGE 2
#define START_SPEED 0.05 #define START_SPEED 0.07
#define SPEEDMUL 1.2 #define SPEEDMUL 1.2
#define MAX_PLAYERS 8 #define MAX_PLAYERS 8
#define MAX_BOMBS 12 #define MAX_BOMBS 12
#define MAX_RANGE 10 #define MAX_RANGE 10
#define MAX_SPEED 40 #define MAX_SPEED 2
#define MAX_BLITRECTS 4096 #define MAX_BLITRECTS 4096
#define MAX_STONESTODRAW 2048 #define MAX_STONESTODRAW 2048
#define MAX_SERVERENTRYS 8 /* number of entrys in the server tab */ #define MAX_SERVERENTRYS 8 /* number of entrys in the server tab */

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.6 2003/11/08 06:27:58 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.7 2003/11/08 19:53:06 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -50,7 +50,8 @@
struct { struct {
float to; // if (to > 0) the ilness is still working float to; // if (to > 0) the ilness is still working
int data; int datai; // hold a integer data (like number of something..)
float dataf; // hold a float data (speed and so on)
} typedef _playerilness; } typedef _playerilness;

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.48 2003/11/08 06:27:58 stpohle Exp $ */ /* $Id: bomb.c,v 1.49 2003/11/08 19:53:07 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -27,8 +27,8 @@ draw_bomb (_bomb * bomb)
dest.w = src.w = gfx.bomb.image->w; dest.w = src.w = gfx.bomb.image->w;
dest.h = src.h = gfx.block.y; dest.h = src.h = gfx.block.y;
dest.x = gfx.offset.x + x * gfx.block.x; dest.x = gfx.offset.x + bomb->pos.x * gfx.block.x;
dest.y = gfx.offset.y + y * gfx.block.y; dest.y = gfx.offset.y + bomb->pos.y * gfx.block.y;
src.x = 0; src.x = 0;
src.y = src.h * (int)bomb->frame; src.y = src.h * (int)bomb->frame;
stonelist_add (x, y); stonelist_add (x, y);
@ -74,8 +74,9 @@ bomb_explode (int p, int b, int net)
void void
bomb_move (_bomb * bomb) bomb_move (_bomb * bomb)
{ {
int step = 0, dist = 0, keepdir = 0; int keepdir = 0;
_pointf fpos, rpos; _pointf fpos, rpos;
float dist = 0.0f, step = 0.0f;
map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; /* delete bfield */ map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; /* delete bfield */
stonelist_add (bomb->pos.x, bomb->pos.y); stonelist_add (bomb->pos.x, bomb->pos.y);
@ -83,27 +84,29 @@ bomb_move (_bomb * bomb)
/* do this once, and again if the direction is still ok */ /* do this once, and again if the direction is still ok */
do { do {
/* get the current position of the bomb */ /* get the current position of the bomb */
fpos.x = rintf (bomb->pos.x); fpos.x = (int) bomb->pos.x;
fpos.y = rintf (bomb->pos.y); fpos.y = (int) bomb->pos.y;
rpos.x = fpos.x - bomb->pos.x; rpos.x = CUTINT(bomb->pos.x);
rpos.y = fpos.y - bomb->pos.y; rpos.y = CUTINT (bomb->pos.y);
if (rpos.x < 0) rpos.x = -rpos.x; // only positive values
if (rpos.y < 0) rpos.y = -rpos.y; // only positive values
/* calculate the next step speed or next full field.. /* calculate the next step speed or next full field..
depend on what is the smaler one */ depend on what is the smaler one */
if (bomb->dest.x < 0) if (bomb->dest.x < 0)
step = rpos.x; step = rpos.x;
else if (bomb->dest.x > 0) else if (bomb->dest.x > 0) {
step = 1.0f - rpos.x; step = 1.0f - rpos.x;
fpos.x += 1.0f;
}
else if (bomb->dest.y < 0) else if (bomb->dest.y < 0)
step = rpos.y; step = rpos.y;
else if (bomb->dest.y > 0) else if (bomb->dest.y > 0) {
step = 1.0f - rpos.y; step = 1.0f - rpos.y;
fpos.y += 1.0f;
}
if (step > (timefactor * bomb->speed) || step == 0) if (step > (timefactor * bomb->speed) || step == 0.0f)
step = (timefactor * bomb->speed); step = (timefactor * bomb->speed);
/* move the bomb to the new position */ /* move the bomb to the new position */
if (bomb->dest.x < 0) if (bomb->dest.x < 0)
bomb->pos.x -= step; bomb->pos.x -= step;
@ -123,8 +126,8 @@ bomb_move (_bomb * bomb)
/* it is a moving liquid bomb so check for another field */ /* it is a moving liquid bomb so check for another field */
_point b, d; _point b, d;
b.x = bomb->pos.x; b.x = (int)bomb->pos.x;
b.y = bomb->pos.y; b.y = (int)bomb->pos.y;
d.x = b.x + bomb->dest.x; d.x = b.x + bomb->dest.x;
d.y = b.y + bomb->dest.y; d.y = b.y + bomb->dest.y;

@ -71,4 +71,9 @@ void debug_ingameinfo() {
redraw_logo (0, gfx.res.y-font[0].size.y, gfx.res.y, gfx.res.x); redraw_logo (0, gfx.res.y-font[0].size.y, gfx.res.y, gfx.res.x);
sprintf (text, "TDiff: %2.3f TFactor: %2.3f", timediff, timefactor); sprintf (text, "TDiff: %2.3f TFactor: %2.3f", timediff, timefactor);
font_gfxdraw (0, gfx.res.y-font[0].size.y, text, 0, (map.size.y*256)+10); font_gfxdraw (0, gfx.res.y-font[0].size.y, text, 0, (map.size.y*256)+10);
if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) {
sprintf (text, "Pos: %2.3f,%2.3f", players[bman.p_nr].pos.x, players[bman.p_nr].pos.y);
font_gfxdraw (350, gfx.res.y-font[0].size.y, text, 0, (map.size.y*256)+10);
}
}; };

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.48 2003/11/08 06:27:58 stpohle Exp $ */ /* $Id: field.c,v 1.49 2003/11/08 19:53:07 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"
@ -189,8 +189,8 @@ draw_stone (int x, int y)
draw_fire (x, y, d, -1); draw_fire (x, y, d, -1);
} }
// if (debug) if (debug)
// font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) + 10); font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) + 10);
return; return;
}; };

@ -311,7 +311,7 @@ stepmove_player (int pl_nr)
/* check if we can go though a tunnel */ /* check if we can go though a tunnel */
if (_pos.x == 0.0f && _pos.y == 0.0f && map.field[(int)p->pos.x][(int)p->pos.y].type == FT_tunnel if (_pos.x == 0.0f && _pos.y == 0.0f && map.field[(int)p->pos.x][(int)p->pos.y].type == FT_tunnel
&& p->tunnelto == -1) { && p->tunnelto <= 0.0f) {
d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n", d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n",
map.field[(int)p->pos.x][(int)p->pos.y].special, p->name, map.field[(int)p->pos.x][(int)p->pos.y].special, p->name,
map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x, map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x,
@ -322,8 +322,8 @@ stepmove_player (int pl_nr)
[map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y]) [map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y])
d_printf (" *** End of tunnel is with an bomb.\n"); d_printf (" *** End of tunnel is with an bomb.\n");
else { else {
p->pos.x = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x << 8; p->pos.x = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x;
p->pos.y = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y << 8; p->pos.y = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y;
p->tunnelto = GAME_TUNNEL_TO; p->tunnelto = GAME_TUNNEL_TO;
speed = p->speed * timefactor; speed = p->speed * timefactor;
} }
@ -370,9 +370,9 @@ move_player (int pl_nr)
oldd = p->d; oldd = p->d;
if (p->tunnelto > 0) { if (p->tunnelto > 0) {
p->tunnelto--; p->tunnelto -= timediff;
p->m = 0; p->m = 0;
if (p->tunnelto <= 0 && GT_MP) if (p->tunnelto <= 0.0f && GT_MP)
net_game_send_playermove (bman.p_nr, 1); net_game_send_playermove (bman.p_nr, 1);
} }
else { else {
@ -608,8 +608,8 @@ player_ilness_loop (int pl_nr)
int type, int type,
pnr, pnr,
i, i,
tmp,
send; send;
float tmpf;
int pl[MAX_PLAYERS + 1]; int pl[MAX_PLAYERS + 1];
/* do the illness for the network players */ /* do the illness for the network players */
@ -618,7 +618,7 @@ player_ilness_loop (int pl_nr)
if (pnr != pl_nr && PS_IS_alife (players[pnr].state)) { if (pnr != pl_nr && PS_IS_alife (players[pnr].state)) {
p = &players[pnr]; p = &players[pnr];
for (type = 0; type < PI_max; type++) for (type = 0; type < PI_max; type++)
if (p->ill[type].to > 0) { if (p->ill[type].to > 0.0f) {
p->ill[type].to -= timediff; p->ill[type].to -= timediff;
p->illframe += timefactor; p->illframe += timefactor;
if (p->illframe < 0 || p->illframe >= gfx.ill.frames) if (p->illframe < 0 || p->illframe >= gfx.ill.frames)
@ -635,10 +635,10 @@ player_ilness_loop (int pl_nr)
send = 0; send = 0;
for (type = 0; type < PI_max; type++) { for (type = 0; type < PI_max; type++) {
if (players[pl[i]].ill[type].to > p->ill[type].to) { if (players[pl[i]].ill[type].to > p->ill[type].to) {
tmp = p->ill[type].to; tmpf = p->ill[type].to;
player_set_ilness (p, type); player_set_ilness (p, type);
p->ill[type].to = players[pl[i]].ill[type].to; p->ill[type].to = players[pl[i]].ill[type].to;
if (tmp <= 0) if (tmpf <= 0.0f)
send = 1; send = 1;
} }
} }
@ -648,14 +648,14 @@ player_ilness_loop (int pl_nr)
/* do the illness for the givin player */ /* do the illness for the givin player */
for (type = 0; type < PI_max; type++) for (type = 0; type < PI_max; type++)
if (p->ill[type].to > 0) { if (p->ill[type].to > 0.0f) {
p->ill[type].to--; p->ill[type].to -= timediff;
if (p->ill[type].to == 0) if (p->ill[type].to <= 0.0f)
player_clear_ilness (p, type); player_clear_ilness (p, type);
else { else {
p->illframe += timediff; p->illframe += timediff;
if (p->illframe < 0 || p->illframe >= gfx.ill.frames) if (p->illframe < 0 || p->illframe >= gfx.ill.frames)
p->illframe = 0; p->illframe = 0.0f;
if (type == PI_keys) { if (type == PI_keys) {
/* switch direction for player key illness */ /* switch direction for player key illness */
@ -697,36 +697,36 @@ player_set_ilness (_player * p, int t)
d_printf ("Ilness : %d\n", type); d_printf ("Ilness : %d\n", type);
switch (type) { switch (type) {
case PI_slow: case PI_slow:
if (p->ill[type].to == 0) { if (p->ill[type].to <= 0.0f) {
if (p->ill[PI_fast].to > 0) { if (p->ill[PI_fast].to > 0.0f) {
p->ill[type].data = p->ill[PI_fast].data; p->ill[type].dataf = p->ill[PI_fast].dataf;
p->ill[PI_fast].to = 0; p->ill[PI_fast].to = 0.0f;
} }
else else
p->ill[type].data = p->speed; p->ill[type].dataf = p->speed;
} }
p->speed = ILL_SLOWSPEED; p->speed = ILL_SLOWSPEED;
break; break;
case PI_fast: case PI_fast:
if (p->ill[type].to == 0) { if (p->ill[type].to <= 0.0f) {
if (p->ill[PI_slow].to > 0) { if (p->ill[PI_slow].to > 0.0f) {
p->ill[type].data = p->ill[PI_slow].data; p->ill[type].dataf = p->ill[PI_slow].dataf;
p->ill[PI_slow].to = 0; p->ill[PI_slow].to = 0.0f;
} }
else else
p->ill[type].data = p->speed; p->ill[type].dataf = p->speed;
} }
p->speed = ILL_FASTSPEED; p->speed = ILL_FASTSPEED;
break; break;
case PI_range: case PI_range:
if (p->ill[type].to == 0) if (p->ill[type].to == 0)
p->ill[type].data = p->range; p->ill[type].datai = p->range;
p->range = 1; p->range = 1;
break; break;
case PI_nobomb: case PI_nobomb:
if (p->ill[type].to == 0) if (p->ill[type].to == 0)
p->ill[type].data = p->bombs_n; p->ill[type].datai = p->bombs_n;
p->bombs_n = s_random (2); p->bombs_n = s_random (2);
break; break;
} }
@ -744,13 +744,13 @@ player_clear_ilness (_player * p, int type)
switch (type) { switch (type) {
case PI_slow: case PI_slow:
case PI_fast: case PI_fast:
p->speed = p->ill[type].data; p->speed = p->ill[type].dataf;
break; break;
case PI_range: case PI_range:
p->range = p->ill[type].data; p->range = p->ill[type].datai;
break; break;
case PI_nobomb: case PI_nobomb:
p->bombs_n = p->ill[type].data; p->bombs_n = p->ill[type].datai;
break; break;
} }
p->ill[type].to = 0; p->ill[type].to = 0;

@ -1,4 +1,4 @@
/* $Id: special.c,v 1.28 2003/11/08 06:27:59 stpohle Exp $ */ /* $Id: special.c,v 1.29 2003/11/08 19:53:07 stpohle Exp $ */
/* special.c - procedues to control the specials */ /* special.c - procedues to control the specials */
#include "bomberclone.h" #include "bomberclone.h"
@ -135,9 +135,9 @@ special_liquidmoved (int p_nr)
|| (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel)) || (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel))
return; return;
get_bomb_on (x, y, bombs); get_bomb_on ((float)x, (float)y, bombs);
// move all bombs on that field (there should be only 1) // move all bombs on that field (there should be only 1)
for (i = 0; bombs[i].x != -1; i++) { for (i = 0; (bombs[i].x != -1) && (i < MAX_PLAYERS * MAX_BOMBS); i++) {
b = &players[bombs[i].x].bombs[bombs[i].y]; b = &players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) { if (b->state != BS_exploding) {
b->dest.x = dx; b->dest.x = dx;

Loading…
Cancel
Save