some work on the single player and bfield fixed by dropping a bomb

origin
stpohle 23 years ago
parent e758bd16d1
commit 69556a00a2

@ -362,7 +362,7 @@ player_drop_bomb (int pl_nr)
bomb->ex_nr = -1;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
bman.bfield [bomb->pos.x][bomb->pos.y] = 1;
if (bman.gametype != GT_single) {
net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS)

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.14 2003/05/13 21:53:40 patty21 Exp $ */
/* $Id: single.c,v 1.15 2003/05/17 17:11:27 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -62,34 +62,82 @@ single_game_new ()
bman.state = GS_running;
};
/* check if is there is a bom in the near
returns the directions (bits 0(left)-3(down)) where a bomb is */
int ai_findnearbombs (_player *pl) {
int d,
res = 0, // result if there is a bomb
dist[4][3]; // to check every direction (on three ways)
done = 0,
row;
_point m[4]; // direction addition
_point dist[4][3]; // to check every direction (on three ways)
for (d = 0; d < 4; d++) {
for (d = 0; d < 4; d++)
switch (d) {
case (left):
m[d].x = -1;
m[d].y = 0;
break;
dist[d][0].x = (pl->pos.x>>8) - 1;
dist[d][1].x = (pl->pos.x>>8) - 1;
dist[d][2].x = (pl->pos.x>>8) - 1;
dist[d][0].y = (pl->pos.y>>8) - 1;
dist[d][1].y = (pl->pos.y>>8);
dist[d][2].y = (pl->pos.y>>8) + 1;
break;
case (right):
m[d].x = 1;
m[d].y = 0;
dist[d][0].x = (pl->pos.x>>8) + 1;
dist[d][1].x = (pl->pos.x>>8) + 1;
dist[d][2].x = (pl->pos.x>>8) + 1;
dist[d][0].y = (pl->pos.y>>8) - 1;
dist[d][1].y = (pl->pos.y>>8);
dist[d][2].y = (pl->pos.y>>8) + 1;
break;
case (up):
m[d].x = 0;
m[d].y = -1;
dist[d][0].x = (pl->pos.x>>8) - 1;
dist[d][1].x = (pl->pos.x>>8);
dist[d][2].x = (pl->pos.x>>8) + 1;
dist[d][0].y = (pl->pos.y>>8) - 1;
dist[d][1].y = (pl->pos.y>>8) - 1;
dist[d][2].y = (pl->pos.y>>8) - 1;
break;
case (down):
m[d].x = 0;
m[d].y = 1;
dist[d][0].x = (pl->pos.x>>8) - 1;
dist[d][1].x = (pl->pos.x>>8);
dist[d][2].x = (pl->pos.x>>8) + 1;
dist[d][0].y = (pl->pos.y>>8) + 1;
dist[d][1].y = (pl->pos.y>>8) + 1;
dist[d][2].y = (pl->pos.y>>8) + 1;
break;
}
};
while (!done) {
done = 1;
/* check every direction again */
for (d = 0; d < 4; d++)
for (row = 0; row < 3; row++)
if (dist[d][row].x >= 0 && dist[d][row].x < bman.fieldsize.x &&
dist[d][row].y >= 0 && dist[d][row].y < bman.fieldsize.y) {
if (bman.bfield[dist[d][row].x][dist[d][row].y] != 0) {
res |= 1 << d; // set the bit for the direction;
dist[d][row].x = dist[d][row].y = -1; // don't check no more.
}
if (bman.field[dist[d][row].x][dist[d][row].y].type != FT_nothing)
dist[d][row].x = dist[d][row].y = -1; // don't check no more.
if (dist[d][row].x != -1 && dist[d][row].y != -1) {
dist[d][row].x += m[d].x;
dist[d][row].y += m[d].y;
done = 0;
}
}
}
return res;
}
@ -104,7 +152,7 @@ single_loop ()
for (p = 0; p < MAX_PLAYERS; p++)
if (p != bman.p_nr && PS_IS_playing (bman.players[p].state)) {
pl = &bman.players[p];
ai_findnearbombs (pl);
player_ilness_loop (p);
}
};
@ -140,7 +188,7 @@ void single_playergame () {
for (p = 0; p < MAX_PLAYERS; p++)
bman.players[p].state = 0;
single_create_ai (4);
single_create_ai (1);
single_game_new ();
gfx_game_init ();
game_loop ();

Loading…
Cancel
Save