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 */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -17,6 +17,7 @@
#define GAME_TIMEOUT 600.0 // game timeout 10min) #define GAME_TIMEOUT 600.0 // game timeout 10min)
#define GAME_OVERTIMEOUT 5.0 // second of remaining the last player #define GAME_OVERTIMEOUT 5.0 // second of remaining the last player
#define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds #define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds
#define HURRYWARN_TO_BLINKING 0.10
#define EXPLOSION_SAVE_DISTANCE 0.25 #define EXPLOSION_SAVE_DISTANCE 0.25
#define SPECIAL_TRIGGER_TIMEOUT 15 #define SPECIAL_TRIGGER_TIMEOUT 15
@ -44,7 +45,7 @@
#define MAX_FIELDANIMATION 2048 /* number of points on the field to be animated exploding #define MAX_FIELDANIMATION 2048 /* number of points on the field to be animated exploding
stoned or powerups*/ stoned or powerups*/
#define EXPLOSIONTIMEOUT 0.75 #define EXPLOSIONTIMEOUT 0.5
#define ANI_FIRETIMEOUT 2 #define ANI_FIRETIMEOUT 2
#define ANI_BOMBTIMEOUT 1 #define ANI_BOMBTIMEOUT 1
#define ANI_PLAYERTIMEOUT 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. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -14,6 +14,8 @@ extern int blitdb_nr,
blitrects_nr; blitrects_nr;
Uint32 game_timediff, game_timediff1; Uint32 game_timediff, game_timediff1;
static float hurrywarn_to;
static int hurrywarn_state;
void void
game_draw_info () game_draw_info ()
@ -29,7 +31,6 @@ game_draw_info ()
if (bman.updatestatusbar) { if (bman.updatestatusbar) {
redraw_logo (0, 0, gfx.res.x, (4.5 * 16)); redraw_logo (0, 0, gfx.res.x, (4.5 * 16));
bman.updatestatusbar = 0;
dest.x = dest.y = 0; dest.x = dest.y = 0;
dest.h = 4.5 *16; dest.h = 4.5 *16;
dest.w = gfx.res.x; dest.w = gfx.res.x;
@ -96,10 +97,28 @@ game_draw_info ()
font_draw (100, 32, "Press F4 to start the game", 0, 0); font_draw (100, 32, "Press F4 to start the game", 0, 0);
else if (bman.state == GS_ready) else if (bman.state == GS_ready)
font_draw (100, 32, "Waiting for the Server to Start", 0, 0); font_draw (100, 32, "Waiting for the Server to Start", 0, 0);
}
/* 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 (map.state == MS_hurrywarn) { if (hurrywarn_state) {
font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 32, "HURRY HURRY", 1, 0, 2); 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, 32, "HURRY HURRY", 1, 1); 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);
} }
} }
@ -108,6 +127,8 @@ game_draw_info ()
if (debug) if (debug)
debug_ingameinfo(); 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. */ /* map handling, like generate and load maps. */
#include "bomberclone.h" #include "bomberclone.h"
@ -162,142 +162,204 @@ map_genrandom ()
/* will set the playerposition but in a way that we won't start on a block */ /* 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 */ /* i am just too lazy to write this all again and again */
#define PLX players[i].pos.x #define PLX(__i) players[__i].pos.x
#define PLY players[i].pos.y #define PLY(__i) players[__i].pos.y
void
map_set_playerposition (int usermap) /* check if there is another player in the near if so delete player pos for another try */
{ void map_playerpos_check (int pl) {
int p, int i, d = MAX_FIELDSIZE_X, dx, dy;
dist, for (i = 0; (i < MAX_PLAYERS && d > 1); i++)
i, if (i != pl) {
j, dx = PLX(i) - PLX(pl);
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) if (dx < 0)
dx = -dx; dx = -dx;
dy = PLY - players[j].pos.y; dy = PLY(i) - PLY(pl);
if (dy < 0) if (dy < 0)
dy = -dy; dy = -dy;
if (dx < dy) // save the biggest distance in there
dx = dy;
if (dx < d)
d = dx;
}
if (d < 2) {
PLX(pl) = -1;
PLY(pl) = -1;
}
} }
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);
/* check if there is no block */ /* check if there is no block */
if ((dx > 1 || dy > 1) if (map.field[p.x][p.y].type != FT_nothing)
&& ((map.field[(int)PLX][(int)PLY].type != FT_block && maxloop > 100) return;
|| 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) || /* check if we can run away somewhere */
map.field[(int)PLX][(int)PLY + dy].type == FT_nothing)) for (j = 0; j < 4; j++) {
dy = -dy; t[j].x = p.x;
if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) || t[j].y = p.y;
map.field[(int)PLX][(int)PLY + dy].type == FT_nothing))
PLY = -1;
}
else {
PLX = -1;
PLY = -1;
} }
/* make some space */ for (i = 0; (i < 10 && ok == 0); i++) {
if (PLX >= 0.0f && PLY >= 0.0f) { t[left].x -= 1;
if (map.field[(int)PLX][(int)PLY].type != FT_tunnel) t[right].x += 1;
map.field[(int)PLX][(int)PLY].type = FT_nothing; t[up].y = -1;
if (map.field[(int)PLX + dx][(int)PLY].type != FT_tunnel) t[down].y += 1;
map.field[(int)PLX + dx][(int)PLY].type = FT_nothing; for (j = 0; j < 4; j++)
if (map.field[(int)PLX][(int)PLY + dy].type != FT_tunnel) if (t[j].x > 0 && t[j].x < map.size.x
map.field[(int)PLX][(int)PLY + dy].type = FT_nothing; && 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 { /* this field is not free anymore */
t[j].x = -1;
t[j].y = -1;
} }
} else {
t[j].x = -1;
t[j].y = -1;
} }
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);
} }
if (ok) {
PLX(pl) = p.x;
PLY(pl) = p.y;
}
}
/* now there will be some fields deleted */ void
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1; map_set_player_way2 (int pl)
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1; {
_point p, t[4];
int i, j, ok = 0;
if (map.field[(int)PLX][(int)PLY].type != FT_tunnel) p.x = s_random (map.size.x - 2) + 1;
map.field[(int)PLX][(int)PLY].type = FT_nothing; p.y = s_random (map.size.y - 2) + 1;
dx = s_random (4); // bit 1 = up/down bit 2 = left/right d_printf ("map_set_player_way2 (%d) : %d,%d\n", pl, p.x, p.y);
/* up and down */
if (((dx & 1) == 0 && PLX > 1.0f) || PLX >= map.size.x - 2) { /* check if there is no block */
if (map.field[(int)PLX - 1][(int)PLY].type != FT_tunnel) if (map.field[p.x][p.y].type != FT_nothing)
map.field[(int)PLX - 1][(int)PLY].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;
} }
else {
if (map.field[(int)PLX + 1][(int)PLY].type != FT_tunnel) for (i = 0; (i < 10 && ok == 0); i++) {
map.field[(int)PLX + 1][(int)PLY].type = FT_nothing; 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;
} }
/* left and right */ if (ok == 0 && (j == left || j == right) && map.field[t[j].x][t[j].y + 1].type == FT_stone) {
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) { map.field[t[j].x][t[j].y + 1].type = FT_nothing;
if (map.field[(int)PLX][(int)PLY - 1].type != FT_tunnel) map.field[t[j].x][t[j].y + 1].special = FT_nothing;
map.field[(int)PLX][(int)PLY - 1].type = FT_nothing; ok = 1;
} }
else { if (ok == 0 && (j == up || j == down) && map.field[t[j].x + 1][t[j].y].type == FT_stone) {
if (map.field[(int)PLX][(int)PLY + 1].type != FT_tunnel) map.field[t[j].x + 1][t[j].y].type = FT_nothing;
map.field[(int)PLX][(int)PLY + 1].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;
} }
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;
} }
else { /* this field is not free anymore */
if (mx > dist || my > dist) t[j].x = -1;
i++; t[j].y = -1;
else }
p++; } 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);
}
}
/* 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);
}
}
/* 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 PLX
#undef PLY #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 */ /* single player */
#include "basic.h" #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 int
ai_easyrunaway (_point p) ai_easyrunaway (_point p)
{ {

Loading…
Cancel
Save