|
|
@ -77,7 +77,6 @@ draw_player (_player * player)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
restore_players_screen ()
|
|
|
|
restore_players_screen ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
int i,
|
|
|
|
int i,
|
|
|
|
x,
|
|
|
|
x,
|
|
|
|
xs,
|
|
|
|
xs,
|
|
|
@ -216,78 +215,102 @@ player_check_powerup (int p_nr)
|
|
|
|
fx,fy = position on the field
|
|
|
|
fx,fy = position on the field
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
int
|
|
|
|
check_field (short int fx, short int fy, _player * p)
|
|
|
|
check_field (short int x, short int y)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_point bombs[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
|
|
|
|
int res = 0;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (bman.field[fx][fy].type != FT_stone && bman.field[fx][fy].type != FT_block)
|
|
|
|
if (bman.field[x][y].type != FT_stone && bman.field[x][y].type != FT_block)
|
|
|
|
res = 1;
|
|
|
|
res = 1;
|
|
|
|
get_bomb_on (fx, fy, bombs);
|
|
|
|
|
|
|
|
if (bombs[0].x != -1)
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* make only a smal step until i can go around the corner
|
|
|
|
|
|
|
|
return the rest speed for this move */
|
|
|
|
int
|
|
|
|
int
|
|
|
|
stepmove_player (int pl_nr)
|
|
|
|
stepmove_player (int pl_nr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
_point bomb1[MAX_PLAYERS * MAX_BOMBS], bomb2[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
_player *p = &bman.players[pl_nr];
|
|
|
|
_player *p = &bman.players[pl_nr];
|
|
|
|
int _x,
|
|
|
|
int speed = 0, i, j, f;
|
|
|
|
_y,
|
|
|
|
_point fpos, // field position
|
|
|
|
dx = 0,
|
|
|
|
_pos, // position inside the field
|
|
|
|
dy = 0,
|
|
|
|
d;
|
|
|
|
fx,
|
|
|
|
|
|
|
|
fy,
|
|
|
|
|
|
|
|
speed = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (p->m == 1) {
|
|
|
|
if (p->m == 1) {
|
|
|
|
|
|
|
|
|
|
|
|
fx = p->pos.x >> 8;
|
|
|
|
fpos.x = p->pos.x >> 8;
|
|
|
|
fy = p->pos.y >> 8;
|
|
|
|
fpos.y = p->pos.y >> 8;
|
|
|
|
_x = p->pos.x & 255;
|
|
|
|
_pos.x = p->pos.x & 255;
|
|
|
|
_y = p->pos.y & 255;
|
|
|
|
_pos.y = p->pos.y & 255;
|
|
|
|
|
|
|
|
|
|
|
|
// do direction correction for going up/down
|
|
|
|
// do direction correction for going up/down
|
|
|
|
if (_x > 0 && _x <= 128 && (p->d == up || p->d == down))
|
|
|
|
if (_pos.x > 0 && _pos.x <= 128 && (p->d == up || p->d == down))
|
|
|
|
p->d = left;
|
|
|
|
p->d = left;
|
|
|
|
if (_x > 128 && _x < 256 && (p->d == up || p->d == down))
|
|
|
|
if (_pos.x > 128 && _pos.x < 256 && (p->d == up || p->d == down))
|
|
|
|
p->d = right;
|
|
|
|
p->d = right;
|
|
|
|
// do direction correction for left/right
|
|
|
|
// do direction correction for left/right
|
|
|
|
if (_y > 0 && _y <= 128 && (p->d == left || p->d == right))
|
|
|
|
if (_pos.y > 0 && _pos.y <= 128 && (p->d == left || p->d == right))
|
|
|
|
p->d = up;
|
|
|
|
p->d = up;
|
|
|
|
if (_y > 128 && _y < 256 && (p->d == left || p->d == right))
|
|
|
|
if (_pos.y > 128 && _pos.y < 256 && (p->d == left || p->d == right))
|
|
|
|
p->d = down;
|
|
|
|
p->d = down;
|
|
|
|
/* get the pos to the next field */
|
|
|
|
|
|
|
|
|
|
|
|
/* get the distance/speed until we reach the next position */
|
|
|
|
if (p->d == left)
|
|
|
|
if (p->d == left)
|
|
|
|
speed = _x;
|
|
|
|
speed = _pos.x;
|
|
|
|
else if (p->d == right)
|
|
|
|
else if (p->d == right)
|
|
|
|
speed = 256 - _x;
|
|
|
|
speed = 256 - _pos.x;
|
|
|
|
else if (p->d == up)
|
|
|
|
else if (p->d == up)
|
|
|
|
speed = _y;
|
|
|
|
speed = _pos.y;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
speed = 256 - _y;
|
|
|
|
speed = 256 - _pos.y;
|
|
|
|
|
|
|
|
|
|
|
|
if (speed > p->speed || speed == 0)
|
|
|
|
if (speed > p->speed || speed == 0)
|
|
|
|
speed = p->speed;
|
|
|
|
speed = p->speed;
|
|
|
|
// go left
|
|
|
|
|
|
|
|
if (p->d == left && _y == 0 && ((_x == 0 && check_field (fx - 1, fy, p)) || (_x > 0)))
|
|
|
|
// check the new field position
|
|
|
|
dx = -speed;
|
|
|
|
d.x = d.y = 0;
|
|
|
|
// go right
|
|
|
|
if (p->d == left && _pos.y == 0 && ((_pos.x == 0 && check_field (fpos.x - 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
if (p->d == right && _y == 0 && ((_x == 0 && check_field (fx + 1, fy, p)) || (_x > 0)))
|
|
|
|
d.x = -speed;
|
|
|
|
dx = speed;
|
|
|
|
if (p->d == right && _pos.y == 0 && ((_pos.x == 0 && check_field (fpos.x + 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
// go up
|
|
|
|
d.x = speed;
|
|
|
|
if (p->d == up && _x == 0 && ((_y == 0 && check_field (fx, fy - 1, p)) || (_y > 0)))
|
|
|
|
if (p->d == up && _pos.x == 0 && ((_pos.y == 0 && check_field (fpos.x, fpos.y - 1)) || (_pos.y > 0)))
|
|
|
|
dy = -speed;
|
|
|
|
d.y = -speed;
|
|
|
|
// go down
|
|
|
|
if (p->d == down && _pos.x == 0 && ((_pos.y == 0 && check_field (fpos.x, fpos.y + 1)) || (_pos.y > 0)))
|
|
|
|
if (p->d == down && _x == 0 && ((_y == 0 && check_field (fx, fy + 1, p)) || (_y > 0)))
|
|
|
|
d.y = speed;
|
|
|
|
dy = speed;
|
|
|
|
|
|
|
|
p->pos.x = p->pos.x + dx;
|
|
|
|
// check if we can move and if there is any bomb
|
|
|
|
p->pos.y = p->pos.y + dy;
|
|
|
|
if (d.y != 0 || d.x != 0) {
|
|
|
|
|
|
|
|
get_bomb_on (p->pos.x, p->pos.y, bomb1);
|
|
|
|
|
|
|
|
get_bomb_on (p->pos.x + d.x, p->pos.y + d.y, bomb2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bomb1[0].x == -1 && bomb2[0].x != -1)
|
|
|
|
|
|
|
|
/* old pos no bomb, new pos no bomb */
|
|
|
|
|
|
|
|
d.x = d.y = 0;
|
|
|
|
|
|
|
|
else if (bomb2[0].x != -1) {
|
|
|
|
|
|
|
|
/* new pos bomb, old pos bomb... check if it's the same
|
|
|
|
|
|
|
|
use f to save if we found the bomb or not
|
|
|
|
|
|
|
|
f == 0 no bomb found, f == 1 bomb found */
|
|
|
|
|
|
|
|
for (i = 0, f = 1; (bomb2[i].x != -1 && f == 1); i++)
|
|
|
|
|
|
|
|
for (f = 0, j = 0; (bomb1[j].x != -1 && f == 0); j++)
|
|
|
|
|
|
|
|
if (bomb1[j].x == bomb2[i].x && bomb1[j].y == bomb2[i].y)
|
|
|
|
|
|
|
|
/* identical bomb found ... f = 1 */
|
|
|
|
|
|
|
|
f = 1;
|
|
|
|
|
|
|
|
if (f == 0)
|
|
|
|
|
|
|
|
d.x = d.y = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p->pos.x += d.x;
|
|
|
|
|
|
|
|
p->pos.y += d.y;
|
|
|
|
|
|
|
|
|
|
|
|
player_check_powerup (pl_nr);
|
|
|
|
player_check_powerup (pl_nr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
if (d.x == 0 && d.y == 0)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return (p->speed - speed);
|
|
|
|
return (p->speed - speed);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -336,7 +359,9 @@ player_drop_bomb (int pl_nr)
|
|
|
|
_x,
|
|
|
|
_x,
|
|
|
|
_y;
|
|
|
|
_y;
|
|
|
|
_point bombs[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
_point bombs[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++);
|
|
|
|
for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++);
|
|
|
|
|
|
|
|
|
|
|
|
if (i < player->bombs_n && PS_IS_alife (player->state)) { // free bomb found
|
|
|
|
if (i < player->bombs_n && PS_IS_alife (player->state)) { // free bomb found
|
|
|
|
// get the best position for the bomb.
|
|
|
|
// get the best position for the bomb.
|
|
|
|
bomb = &player->bombs[i];
|
|
|
|
bomb = &player->bombs[i];
|
|
|
@ -358,7 +383,6 @@ player_drop_bomb (int pl_nr)
|
|
|
|
_y = 0;
|
|
|
|
_y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_bomb_on (bomb->pos.x, bomb->pos.y, bombs);
|
|
|
|
get_bomb_on (bomb->pos.x, bomb->pos.y, bombs);
|
|
|
|
if (bombs[0].x != -1) // is there already a bomb
|
|
|
|
if (bombs[0].x != -1) // is there already a bomb
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|