playerpositions at starttime fixed (complete rewritten)

explosion time cut down from 0.75 seconds to 0.5seconds.
origin
stpohle 22 years ago
parent 702472a247
commit 7a99299749

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.10 2003/12/28 01:21:42 stpohle Exp $ */
/* $Id: basic.h,v 1.11 2003/12/28 04:51:24 stpohle Exp $ */
/* basic types which we need everywhere */
#ifndef _BC_BASIC_H_
@ -17,6 +17,7 @@
#define GAME_TIMEOUT 600.0 // game timeout 10min)
#define GAME_OVERTIMEOUT 5.0 // second of remaining the last player
#define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds
#define HURRYWARN_TO_BLINKING 0.10
#define EXPLOSION_SAVE_DISTANCE 0.25
#define SPECIAL_TRIGGER_TIMEOUT 15
@ -44,7 +45,7 @@
#define MAX_FIELDANIMATION 2048 /* number of points on the field to be animated exploding
stoned or powerups*/
#define EXPLOSIONTIMEOUT 0.75
#define EXPLOSIONTIMEOUT 0.5
#define ANI_FIRETIMEOUT 2
#define ANI_BOMBTIMEOUT 1
#define ANI_PLAYERTIMEOUT 1

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.63 2003/12/28 01:35:35 stpohle Exp $
/* $Id: game.c,v 1.64 2003/12/28 04:51:25 stpohle Exp $
game.c - procedures for the game. */
#include <string.h>
@ -14,6 +14,8 @@ extern int blitdb_nr,
blitrects_nr;
Uint32 game_timediff, game_timediff1;
static float hurrywarn_to;
static int hurrywarn_state;
void
game_draw_info ()
@ -29,7 +31,6 @@ game_draw_info ()
if (bman.updatestatusbar) {
redraw_logo (0, 0, gfx.res.x, (4.5 * 16));
bman.updatestatusbar = 0;
dest.x = dest.y = 0;
dest.h = 4.5 *16;
dest.w = gfx.res.x;
@ -96,18 +97,38 @@ game_draw_info ()
font_draw (100, 32, "Press F4 to start the game", 0, 0);
else if (bman.state == GS_ready)
font_draw (100, 32, "Waiting for the Server to Start", 0, 0);
if (map.state == MS_hurrywarn) {
font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 32, "HURRY HURRY", 1, 0, 2);
font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 32, "HURRY HURRY", 1, 1);
}
}
/* draw the warning part */
if (map.state != MS_normal) {
hurrywarn_to -= timediff;
if (bman.updatestatusbar || hurrywarn_to <= 0.0 || hurrywarn_to > HURRYWARN_TO_BLINKING) {
hurrywarn_to = HURRYWARN_TO_BLINKING;
hurrywarn_state = !hurrywarn_state;
if (hurrywarn_state) {
font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 0, 2);
font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1);
}
else {
font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1, 2);
font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 0);
}
dest.x = dest.y = 0;
dest.h = 4.5 *16;
dest.w = gfx.res.x;
gfx_blitupdaterectadd (&dest);
}
}
if (chat.visible == 0 && GT_MP)
chat_show (4, 4.5*16, gfx.res.x - 4, gfx.offset.y);
if (debug)
debug_ingameinfo();
bman.updatestatusbar = 0;
};

@ -1,4 +1,4 @@
/* $Id: map.c,v 1.15 2003/12/28 01:35:35 stpohle Exp $ */
/* $Id: map.c,v 1.16 2003/12/28 04:51:25 stpohle Exp $ */
/* map handling, like generate and load maps. */
#include "bomberclone.h"
@ -10,9 +10,9 @@ void
map_fillitems (int fieldtype, int num)
{
int nb_try = 100,
d,
x,
y;
d,
x,
y;
/* this is the item factor we multiply it with this so we know
how much items we want in the game */
float fkt = ((float) (map.size.x * map.size.y)) / (25.0 * 17.0);
@ -26,8 +26,8 @@ map_fillitems (int fieldtype, int num)
if (nb_try < 0)
break;
}
if (map.field[x][y].type != FT_tunnel)
map.field[x][y].special = fieldtype;
if (map.field[x][y].type != FT_tunnel)
map.field[x][y].special = fieldtype;
}
}
@ -39,59 +39,59 @@ map_new (char *filename)
int x,
y;
FILE *fmap;
signed char old_maptype = map.type;
signed char old_maptype = map.type;
if (filename) {
fmap = fopen (filename, "r");
/* if we can't open the given filename for any reason, reverting
to default value else, load the file map*/
to default value else, load the file map */
if (fmap)
map_load (fmap);
}
else
fmap = NULL;
// Clean and create the field //
if (fmap == NULL)
map_genrandom ();
if (map.type == -1)
map.type = s_random (MAPT_max);
if (map.type == MAPT_tunnel) {
/* insert tunnels */
for (x = 0; x < GAME_MAX_TUNNELS; x++)
map.tunnel[x].x = map.tunnel[x].y = -1;
map.field[3][3].type = FT_tunnel;
map.field[3][3].special = 0;
map.field[map.size.x - 4][map.size.y - 4].type = FT_tunnel;
map.field[map.size.x - 4][map.size.y - 4].special = 1;
if (map.size.y > 12) {
map.field[map.size.x - 4][3].type = FT_tunnel;
map.field[map.size.x - 4][3].special = 2;
map.field[3][map.size.y - 4].type = FT_tunnel;
map.field[3][map.size.y - 4].special = 3;
map.tunnel[0].x = map.size.x - 4;
map.tunnel[0].y = 3;
map.tunnel[1].x = 3;
map.tunnel[1].y = map.size.y - 4;
map.tunnel[2].x = map.size.x - 4;
map.tunnel[2].y = map.size.y - 4;
map.tunnel[3].x = 3;
map.tunnel[3].y = 3;
}
else {
map.tunnel[0].x = map.size.x - 4;
map.tunnel[0].y = map.size.y - 4;
map.tunnel[1].x = 3;
map.tunnel[1].y = 3;
}
}
if (map.type == -1)
map.type = s_random (MAPT_max);
if (map.type == MAPT_tunnel) {
/* insert tunnels */
for (x = 0; x < GAME_MAX_TUNNELS; x++)
map.tunnel[x].x = map.tunnel[x].y = -1;
map.field[3][3].type = FT_tunnel;
map.field[3][3].special = 0;
map.field[map.size.x - 4][map.size.y - 4].type = FT_tunnel;
map.field[map.size.x - 4][map.size.y - 4].special = 1;
if (map.size.y > 12) {
map.field[map.size.x - 4][3].type = FT_tunnel;
map.field[map.size.x - 4][3].special = 2;
map.field[3][map.size.y - 4].type = FT_tunnel;
map.field[3][map.size.y - 4].special = 3;
map.tunnel[0].x = map.size.x - 4;
map.tunnel[0].y = 3;
map.tunnel[1].x = 3;
map.tunnel[1].y = map.size.y - 4;
map.tunnel[2].x = map.size.x - 4;
map.tunnel[2].y = map.size.y - 4;
map.tunnel[3].x = 3;
map.tunnel[3].y = 3;
}
else {
map.tunnel[0].x = map.size.x - 4;
map.tunnel[0].y = map.size.y - 4;
map.tunnel[1].x = 3;
map.tunnel[1].y = 3;
}
}
/* delete the bfield data */
for (x = 0; x < MAX_FIELDSIZE_X; x++)
for (y = 0; y < MAX_FIELDSIZE_Y; y++)
@ -119,7 +119,7 @@ map_new (char *filename)
map_fillitems (FT_sp_liquid, map.sp_push);
map_fillitems (FT_sp_moved, map.sp_push);
map.type = old_maptype;
map.type = old_maptype;
}
void
@ -162,142 +162,204 @@ map_genrandom ()
/* will set the playerposition but in a way that we won't start on a block */
/* i am just too lazy to write this all again and again */
#define PLX players[i].pos.x
#define PLY players[i].pos.y
void
map_set_playerposition (int usermap)
{
int p,
dist,
i,
j,
mx,
my,
dx = 0,
dy = 0;
char txt[255];
p = 50;
dist = 8;
while (p == 50) {
p = 0;
dist--;
for (i = 0; (p < 50 && i < MAX_PLAYERS);)
if (PS_IS_playing (players[i].state))
{
int maxloop = 0;
while (maxloop < 200 && (PLX == -1 || PLY == -1)) {
maxloop++;
PLX = s_random (map.size.x - 2) + 1;
PLY = s_random (map.size.y - 2) + 1;
for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */
dx = PLX - players[j].pos.x;
if (dx < 0)
dx = -dx;
dy = PLY - players[j].pos.y;
if (dy < 0)
dy = -dy;
}
/* check if there is no block */
if ((dx > 1 || dy > 1)
&& ((map.field[(int)PLX][(int)PLY].type != FT_block && maxloop > 100)
|| map.field[(int)PLX][(int)PLY].type == FT_nothing)) {
/* get (up or down) dx and (left or right) dy */
dx = s_random (2);
if (dx == 0)
dx = -1;
dy = s_random (2);
if (dy == 0)
dy = -1;
/* first check if there is a free place for us */
if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) ||
map.field[(int)PLX + dx][(int)PLY].type == FT_nothing))
dx = -dx;
if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) ||
map.field[(int)PLX + dx][(int)PLY].type == FT_nothing))
PLX = -1;
if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) ||
map.field[(int)PLX][(int)PLY + dy].type == FT_nothing))
dy = -dy;
if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) ||
map.field[(int)PLX][(int)PLY + dy].type == FT_nothing))
PLY = -1;
}
else {
PLX = -1;
PLY = -1;
}
/* make some space */
if (PLX >= 0.0f && PLY >= 0.0f) {
if (map.field[(int)PLX][(int)PLY].type != FT_tunnel)
map.field[(int)PLX][(int)PLY].type = FT_nothing;
if (map.field[(int)PLX + dx][(int)PLY].type != FT_tunnel)
map.field[(int)PLX + dx][(int)PLY].type = FT_nothing;
if (map.field[(int)PLX][(int)PLY + dy].type != FT_tunnel)
map.field[(int)PLX][(int)PLY + dy].type = FT_nothing;
}
}
if (PLX < 0 || PLY < 0) {
/* we could not set all fields or we don't run on a usermap */
if (usermap) {
sprintf (txt, "Not all players could be set (Pl:%d)", i);
// menu_displaymessage ("MAP - ERROR", txt);
}
#define PLX(__i) players[__i].pos.x
#define PLY(__i) players[__i].pos.y
/* check if there is another player in the near if so delete player pos for another try */
void map_playerpos_check (int pl) {
int i, d = MAX_FIELDSIZE_X, dx, dy;
for (i = 0; (i < MAX_PLAYERS && d > 1); i++)
if (i != pl) {
dx = PLX(i) - PLX(pl);
if (dx < 0)
dx = -dx;
dy = PLY(i) - PLY(pl);
if (dy < 0)
dy = -dy;
if (dx < dy) // save the biggest distance in there
dx = dy;
if (dx < d)
d = dx;
}
/* now there will be some fields deleted */
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1;
if (d < 2) {
PLX(pl) = -1;
PLY(pl) = -1;
}
}
if (map.field[(int)PLX][(int)PLY].type != FT_tunnel)
map.field[(int)PLX][(int)PLY].type = FT_nothing;
void
map_set_player_way1 (int pl)
{
_point p, t[4];
int i, j, ok = 0;
p.x = s_random (map.size.x - 2) + 1;
p.y = s_random (map.size.y - 2) + 1;
d_printf ("map_set_player_way2 (%d) : %d,%d\n", pl, p.x, p.y);
dx = s_random (4); // bit 1 = up/down bit 2 = left/right
/* up and down */
if (((dx & 1) == 0 && PLX > 1.0f) || PLX >= map.size.x - 2) {
if (map.field[(int)PLX - 1][(int)PLY].type != FT_tunnel)
map.field[(int)PLX - 1][(int)PLY].type = FT_nothing;
/* check if there is no block */
if (map.field[p.x][p.y].type != FT_nothing)
return;
/* check if we can run away somewhere */
for (j = 0; j < 4; j++) {
t[j].x = p.x;
t[j].y = p.y;
}
for (i = 0; (i < 10 && ok == 0); i++) {
t[left].x -= 1;
t[right].x += 1;
t[up].y = -1;
t[down].y += 1;
for (j = 0; j < 4; j++)
if (t[j].x > 0 && t[j].x < map.size.x
&& t[j].y > 0 && t[j].y < map.size.y) {
if (map.field[t[j].x][t[j].y].type == FT_nothing) {
if ((j == left || j == right)
&& map.field[t[j].x][t[j].y - 1].type == FT_nothing
&& map.field[t[j].x][t[j].y + 1].type == FT_nothing)
ok = 1;
if ((j == up || j == down)
&& map.field[t[j].x - 1][t[j].y].type == FT_nothing
&& map.field[t[j].x + 1][t[j].y].type == FT_nothing)
ok = 1;
}
else {
if (map.field[(int)PLX + 1][(int)PLY].type != FT_tunnel)
map.field[(int)PLX + 1][(int)PLY].type = FT_nothing;
else { /* this field is not free anymore */
t[j].x = -1;
t[j].y = -1;
}
/* left and right */
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) {
if (map.field[(int)PLX][(int)PLY - 1].type != FT_tunnel)
map.field[(int)PLX][(int)PLY - 1].type = FT_nothing;
} else {
t[j].x = -1;
t[j].y = -1;
}
}
if (ok) {
PLX(pl) = p.x;
PLY(pl) = p.y;
}
}
void
map_set_player_way2 (int pl)
{
_point p, t[4];
int i, j, ok = 0;
p.x = s_random (map.size.x - 2) + 1;
p.y = s_random (map.size.y - 2) + 1;
d_printf ("map_set_player_way2 (%d) : %d,%d\n", pl, p.x, p.y);
/* check if there is no block */
if (map.field[p.x][p.y].type != FT_nothing)
return;
/* check if we can run away somewhere */
for (j = 0; j < 4; j++) {
t[j].x = p.x;
t[j].y = p.y;
}
for (i = 0; (i < 10 && ok == 0); i++) {
t[left].x -= 1;
t[right].x += 1;
t[up].y = -1;
t[down].y += 1;
for (j = 0; j < 4; j++)
if (t[j].x > 0 && t[j].x < map.size.x
&& t[j].y > 0 && t[j].y < map.size.y) {
if (map.field[t[j].x][t[j].y].type == FT_nothing) {
if (ok == 0 && (j == left || j == right) && map.field[t[j].x][t[j].y - 1].type == FT_stone) {
map.field[t[j].x][t[j].y - 1].type = FT_nothing;
map.field[t[j].x][t[j].y - 1].special = FT_nothing;
ok = 1;
}
if (ok == 0 && (j == left || j == right) && map.field[t[j].x][t[j].y + 1].type == FT_stone) {
map.field[t[j].x][t[j].y + 1].type = FT_nothing;
map.field[t[j].x][t[j].y + 1].special = FT_nothing;
ok = 1;
}
if (ok == 0 && (j == up || j == down) && map.field[t[j].x + 1][t[j].y].type == FT_stone) {
map.field[t[j].x + 1][t[j].y].type = FT_nothing;
map.field[t[j].x + 1][t[j].y].special = FT_nothing;
ok = 1;
}
if (ok == 0 && (j == up || j == down) && map.field[t[j].x - 1][t[j].y].type == FT_stone) {
map.field[t[j].x - 1][t[j].y].type = FT_nothing;
map.field[t[j].x - 1][t[j].y].special = FT_nothing;
ok = 1;
}
}
else {
if (map.field[(int)PLX][(int)PLY + 1].type != FT_tunnel)
map.field[(int)PLX][(int)PLY + 1].type = FT_nothing;
else { /* this field is not free anymore */
t[j].x = -1;
t[j].y = -1;
}
} else {
t[j].x = -1;
t[j].y = -1;
}
}
if (ok) {
PLX(pl) = p.x;
PLY(pl) = p.y;
}
}
void
map_set_playerposition (int usermap)
{
int pl,
ready,
maxtry;
/* try to set every player on a good place */
maxtry = 300;
ready = 0;
while (!ready && maxtry-- > 0) {
ready = 1;
for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
/* set player */
ready = 0;
map_set_player_way1 (pl);
map_playerpos_check (pl);
}
mx = my = 100;
for (j = 0; j <= i; j++) { /* search smalest distance */
dy = PLY - players[j].pos.y;
dx = PLX - players[j].pos.x;
if (dy < 0)
dy = -dy;
if (dx < 0)
dx = -dx;
if (mx > dx && i != j)
mx = dx;
if (my > dy && i != j)
my = dy;
}
/* every player which is still not set .. set now and delete some normal stones */
maxtry = 200;
ready = 0;
while (!ready && maxtry-- > 0) {
ready = 1;
for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
/* set player */
ready = 0;
map_set_player_way2 (pl);
if (maxtry > 50)
map_playerpos_check (pl);
}
}
if (mx > dist || my > dist)
i++;
else
p++;
/* every player who is still not set ... let them die before they
* can play put a warning on the screen */
maxtry = 0; // mark our warning
for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
PLX (pl) = 0.0;
PLY (pl) = 0.0;
maxtry = 1;
}
}
if (maxtry)
d_fatal ("Not All Player could been set\n");
};
#undef PLX
#undef PLY

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.51 2003/12/24 02:38:16 stpohle Exp $ */
/* $Id: single.c,v 1.52 2003/12/28 04:51:25 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -43,7 +43,9 @@ ai_checkfield (int x, int y)
}
/* give the run away direction */
/* give the run away direction
* this function is even needed for the start of
* the game to place the players on a good position */
int
ai_easyrunaway (_point p)
{

Loading…
Cancel
Save