SinglePlayer setp 1 - you will see now some singleplayers. But they are still not walking.. but illness and all this will already work on them

origin
stpohle 23 years ago
parent 008a712d21
commit 871e349f63

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.19 2003/05/11 03:27:18 patty21 Exp $ */ /* $Id: bomberclone.h,v 1.20 2003/05/11 17:27:30 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -192,7 +192,7 @@ extern void player_calcstep (_player * pl);
extern void player_calcpos (); extern void player_calcpos ();
extern void player_set_ilness (_player *p, int t); extern void player_set_ilness (_player *p, int t);
extern void player_clear_ilness (_player *p, int type); extern void player_clear_ilness (_player *p, int type);
extern void player_ilness_loop (); extern void player_ilness_loop (int pl_nr);
extern void player_check_powerup (_player * p); extern void player_check_powerup (_player * p);
extern void player_set_gfx (_player *p, signed char gfx_nr); extern void player_set_gfx (_player *p, signed char gfx_nr);
@ -231,8 +231,9 @@ extern void d_printf (char *fmt,...);
// single.c // single.c
extern void single_game_new (); extern void single_game_new ();
extern void single_create_ai (); extern void single_create_ai (int players);
extern void single_loop(); extern void single_loop();
extern void single_playergame ();
// mapmenu.c // mapmenu.c
extern void map_random (); extern void map_random ();

@ -11,7 +11,8 @@
extern int UpdateRects_nr; extern int UpdateRects_nr;
static Uint32 timediff; static Uint32 timediff,
timediff1;
void void
game_draw_info () game_draw_info ()
@ -21,14 +22,19 @@ game_draw_info ()
j; j;
char text[255]; char text[255];
char scrtext[255]; char scrtext[255];
SDL_Rect src, dest; SDL_Rect src,
dest;
redraw_logo (0, 0, gfx.res.x, 3*16); redraw_logo (0, 0, gfx.res.x, 3 * 16);
if (bman.updatestatusbar) {gfx_AddUpdateRect (0,0, gfx.res.x, 3*16);bman.updatestatusbar=0;} if (bman.updatestatusbar) {
gfx_AddUpdateRect (0, 0, gfx.res.x, 3 * 16);
bman.updatestatusbar = 0;
}
bman.players_nr = 0; bman.players_nr = 0;
/* draw Player names */
if (GT_MP_PTP) { if (GT_MP_PTP) {
/* In Multiplayer mode draw Player names and
count the players who are still alife. */
for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++) for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSFM_used) != 0) { if ((bman.players[i].state & PSFM_used) != 0) {
@ -63,6 +69,12 @@ game_draw_info ()
} }
} }
} }
else
/* in single mode count the player's who are still alife */
for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_alife (bman.players[i].state))
bman.players_nr++;
x = gfx.res.x - 120; x = gfx.res.x - 120;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n); sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n);
@ -76,22 +88,21 @@ game_draw_info ()
draw_text (100, 32, "Press F4 to start the game", 1); draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready) else if (bman.state == GS_ready)
draw_text (100, 32, "Waiting for the Server to Start", 1); draw_text (100, 32, "Waiting for the Server to Start", 1);
// gfx_AddUpdateRect (100, 32, gfx.res.x - 100, 16);
redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y); redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y);
if (debug) { /* do some debug informations on the screen */ if (debug) { /* do some debug informations on the screen */
for (x = 0; x < bman.fieldsize.x; x++) for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y-1); draw_stone (x, bman.fieldsize.y - 1);
if (GT_MP_PTP) { if (GT_MP_PTP) {
sprintf (text, "NET_STAT: ["); sprintf (text, "NET_STAT: [");
for (i = 0 ; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set); sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set);
text[strlen(text)+1] = 0; text[strlen (text) + 1] = 0;
text[strlen(text)] = ']'; text[strlen (text)] = ']';
draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1); draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1);
} }
sprintf (text, "TILESET: %s Timediff: %d", gfx.tileset, timediff); sprintf (text, "TILESET: %s Tframe: %d Tloop: %d", gfx.tileset, timediff, timediff1);
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr); sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - gfx.font.size.y, text, 1); draw_text (0, gfx.res.y - gfx.font.size.y, text, 1);
gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1); gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1);
@ -99,7 +110,7 @@ game_draw_info ()
} }
if (chat.visible == 0 && GT_MP_PTP) { if (chat.visible == 0 && GT_MP_PTP) {
chat_show (4, 3*16, gfx.res.x - 4, gfx.offset.y); chat_show (4, 3 * 16, gfx.res.x - 4, gfx.offset.y);
} }
}; };
@ -111,7 +122,6 @@ game_loop ()
Uint8 *keys; Uint8 *keys;
int done = 0; int done = 0;
Uint32 timeloop1; Uint32 timeloop1;
int move=0;
int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key unsigned char key_bomb = 0; // last state of the bomb key
@ -125,7 +135,8 @@ game_loop ()
timestamp = SDL_GetTicks (); // needed for time sync. timestamp = SDL_GetTicks (); // needed for time sync.
d_gamedetail ("GAME START"); d_gamedetail ("GAME START");
draw_players(); draw_players ();
while (!done && (bman.state == GS_running || bman.state == GS_ready)) { while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if (SDL_PollEvent (&event) != 0) if (SDL_PollEvent (&event) != 0)
switch (event.type) { switch (event.type) {
@ -176,10 +187,13 @@ game_loop ()
bman.state = GS_startup; bman.state = GS_startup;
done = 1; done = 1;
} }
move=bman.players[bman.p_nr].m;
chat_loop (&event); chat_loop (&event);
if (move ||dead_playerani () || GT_MP_PTP) restore_players_screen ();
player_ilness_loop (); restore_players_screen ();
dead_playerani ();
player_ilness_loop (bman.p_nr);
if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife) if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife)
move_player (); move_player ();
@ -192,19 +206,14 @@ game_loop ()
/* this will even set the variable "bman.player_nr" /* this will even set the variable "bman.player_nr"
to let us know how much Players are still left */ to let us know how much Players are still left */
bomb_loop ();
if (bomb_loop () || move || GT_MP_PTP) draw_players (); draw_players ();
move=0;
game_draw_info (); game_draw_info ();
gfx_UpdateRects (); gfx_UpdateRects ();
/* check if there is only one player left and the game is in multiplayer mode /* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */ and if there the last dieing animation is done */
if ((GT_MP_PTPM) && bman.players_nr < 2) if (bman.players_nr < 2)
gameovertimeout--;
/* check if we died and we are in single mode and the animation is done */
if (bman.gametype == GT_single && !PS_IS_alife(bman.players[bman.p_nr].state))
gameovertimeout--; gameovertimeout--;
if (gameovertimeout <= 0) { if (gameovertimeout <= 0) {
@ -221,6 +230,7 @@ game_loop ()
timeloop1 = SDL_GetTicks (); timeloop1 = SDL_GetTicks ();
} }
timediff1 = timeloop1 - timestamp;
timestamp = timeloop1; timestamp = timeloop1;
} }
@ -249,8 +259,6 @@ game_end ()
/* check which player is now free ,i.e. disconnected during the game and was playing */ /* check which player is now free ,i.e. disconnected during the game and was playing */
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSF_used ) == 0) if ((bman.players[i].state & PSF_used) == 0)
bman.players[i].state = 0; bman.players[i].state = 0;
} }

@ -52,11 +52,7 @@ main (int argc, char **argv)
switch (menuselect) { switch (menuselect) {
case (0) : // Singleplayer case (0) : // Singleplayer
single_game_new (); single_playergame ();
single_create_ai ();
gfx_game_init ();
game_loop ();
gfx_game_shutdown ();
break; break;
case (1) : // Multiplayer case (1) : // Multiplayer
netmenu(); netmenu();

@ -60,7 +60,6 @@ restore_players_screen ()
x, x,
xs, xs,
xe, xe,
y, y,
ys, ys,
ye; ye;
@ -86,12 +85,13 @@ restore_players_screen ()
ys = 0; ys = 0;
if (ye >= bman.fieldsize.y) if (ye >= bman.fieldsize.y)
ye = bman.fieldsize.y - 1; ye = bman.fieldsize.y - 1;
xs=x; xs = x;
for (; x <= xe; x++) for (; x <= xe; x++)
for (y = ys; y <= ye; y++) for (y = ys; y <= ye; y++)
draw_stone (x, y); draw_stone (x, y);
gfx_AddUpdateRect(xs*gfx.block.x+gfx.offset.x,ys*gfx.block.y+gfx.offset.y,gfx.block.x*3,gfx.block.y*3); gfx_AddUpdateRect (xs * gfx.block.x + gfx.offset.x, ys * gfx.block.y + gfx.offset.y,
gfx.block.x * 3, gfx.block.y * 3);
} }
}; };
@ -104,7 +104,8 @@ player_check_powerup (_player * p)
int fy = p->pos.y >> 8; int fy = p->pos.y >> 8;
int _x = p->pos.x & 255; int _x = p->pos.x & 255;
int _y = p->pos.y & 255; int _y = p->pos.y & 255;
int ft,i; int ft,
i;
/* Get the right field position */ /* Get the right field position */
if (_x > 128) if (_x > 128)
@ -113,25 +114,35 @@ player_check_powerup (_player * p)
if (_y > 128) if (_y > 128)
fy = fy + 1; fy = fy + 1;
ft=bman.field[fx][fy].type; ft = bman.field[fx][fy].type;
/* we found a mixed powerup */ /* we found a mixed powerup */
if (ft==FT_mixed) { if (ft == FT_mixed) {
i=s_random(6); i = s_random (6);
switch (i) { switch (i) {
case 0:ft=FT_bomb;break; case 0:
case 1:ft=FT_fire;break; ft = FT_bomb;
case 2:ft=FT_shoe;break; break;
case 1:
ft = FT_fire;
break;
case 2:
ft = FT_shoe;
break;
case 3: case 3:
case 4: case 4:
case 5:ft=FT_death;break; case 5:
ft = FT_death;
break;
} }
} }
switch(ft) { switch (ft) {
/* we found a bomb powerup */ /* we found a bomb powerup */
case FT_bomb: case FT_bomb:
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0) if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0) {
{p->bombs_n++;bman.updatestatusbar=1;} p->bombs_n++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -139,8 +150,10 @@ player_check_powerup (_player * p)
/* we found a fire powerup */ /* we found a fire powerup */
case FT_fire: case FT_fire:
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) {
{p->range++;bman.updatestatusbar=1;} p->range++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -148,8 +161,10 @@ player_check_powerup (_player * p)
/* we found a shoe powerup */ /* we found a shoe powerup */
case FT_shoe: case FT_shoe:
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) {
{p->speed *= SPEEDMUL;bman.updatestatusbar=1;} p->speed *= SPEEDMUL;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -158,7 +173,8 @@ player_check_powerup (_player * p)
/* we found a death ?powerup? */ /* we found a death ?powerup? */
case FT_death: case FT_death:
player_set_ilness (p, -1); player_set_ilness (p, -1);
bman.updatestatusbar=1; bman.updatestatusbar = 1;
if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
@ -389,6 +405,7 @@ player_died (_player * player, signed char dead_by)
player->state &= (0xFF - PSF_alife); player->state &= (0xFF - PSF_alife);
player->dead_by = dead_by; player->dead_by = dead_by;
if (GT_MP_PTP)
net_game_send_player (bman.p_nr); net_game_send_player (bman.p_nr);
}; };
@ -428,12 +445,15 @@ player_animation (_player * player)
int int
dead_playerani () dead_playerani ()
{ {
int i,b=0; int i,
b = 0;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_dead (bman.players[i].state)) if (PS_IS_dead (bman.players[i].state)) {
{player_animation (&bman.players[i]);b++;} player_animation (&bman.players[i]);
return b; b++;
}
return b;
}; };
@ -505,7 +525,7 @@ player_calcpos ()
void void
player_ilness_loop () player_ilness_loop (int pl_nr)
{ {
_player *p; _player *p;
int type, int type,
@ -516,8 +536,9 @@ player_ilness_loop ()
int pl[MAX_PLAYERS + 1]; int pl[MAX_PLAYERS + 1];
/* do the illness for the network players */ /* do the illness for the network players */
if (GT_MP_PTP) {
for (pnr = 0; pnr < MAX_PLAYERS; pnr++) for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
if (pnr != bman.p_nr && PS_IS_alife (bman.players[pnr].state)) { if (pnr != pl_nr && PS_IS_alife (bman.players[pnr].state)) {
p = &bman.players[pnr]; p = &bman.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) {
@ -531,13 +552,13 @@ player_ilness_loop ()
} }
} }
} }
}
/* check if we have contact with an other ill player */ /* check if we have contact with an other ill player */
p = &bman.players[bman.p_nr]; p = &bman.players[pl_nr];
get_player_on (p->pos.x, p->pos.y, pl); get_player_on (p->pos.x, p->pos.y, pl);
for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++) for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++)
if (pl[i] != bman.p_nr) { if (pl[i] != pl_nr) {
send = 0; send = 0;
for (type = 0; type < PI_max; type++) { for (type = 0; type < PI_max; type++) {
if (bman.players[pl[i]].ill[type].to > p->ill[type].to) { if (bman.players[pl[i]].ill[type].to > p->ill[type].to) {
@ -548,11 +569,11 @@ player_ilness_loop ()
send = 1; send = 1;
} }
} }
if (send != 0) if (send != 0 && GT_MP_PTP)
net_game_send_ill (bman.p_nr); net_game_send_ill (pl_nr);
} }
/* do the illness for our own 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) {
p->ill[type].to--; p->ill[type].to--;
@ -644,7 +665,7 @@ player_set_ilness (_player * p, int t)
break; break;
} }
bman.updatestatusbar=1; bman.updatestatusbar = 1;
p->ill[type].to += TIME_FACTOR * IL_TIMEOUT; p->ill[type].to += TIME_FACTOR * IL_TIMEOUT;
}; };
@ -669,8 +690,9 @@ player_clear_ilness (_player * p, int type)
} }
p->ill[type].to = 0; p->ill[type].to = 0;
if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.updatestatusbar=1; bman.updatestatusbar = 1;
}; };

@ -1,19 +1,28 @@
/* $Id: single.c,v 1.10 2003/05/08 14:35:49 stpohle Exp $ */ /* $Id: single.c,v 1.11 2003/05/11 17:27:30 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
#include "bomberclone.h" #include "bomberclone.h"
void void
single_game_new (int ai_players) single_game_new ()
{ {
int p, int p,
i; i;
// set players on field 1,1 bman.players_nr_s = 1;
bman.players_nr = 1;
// set players variables
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = -1; bman.players[p].pos.x = -1;
bman.players[p].pos.y = -1; bman.players[p].pos.y = -1;
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
bman.players_nr++;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing;
}
else
bman.players[p].state = 0; bman.players[p].state = 0;
// reset bombs // reset bombs
@ -32,35 +41,73 @@ single_game_new (int ai_players)
bman.players[p].d = 0; bman.players[p].d = 0;
} }
bman.p_nr = 0; for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state)))
bman.p_nr = p;
if (bman.p_nr >= MAX_PLAYERS) {
printf ("ERROR in function (single_game_new): couldn't find any free player\n");
exit (1);
}
bman.players[bman.p_nr].state = PSFM_alife; bman.players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], 0); player_set_gfx (&bman.players[bman.p_nr], 0);
bman.last_ex_nr = 1; bman.last_ex_nr = 1;
init_map_tileset(); init_map_tileset ();
bman.players_nr_s = 1;
bman.players_nr = 1;
bman.gametype = GT_single; bman.gametype = GT_single;
bman.state = GS_running; bman.state = GS_running;
}; };
void single_loop () { void
single_loop ()
{
int p;
_player *pl;
for (p = 0; p < MAX_PLAYERS; p++)
if (p != bman.p_nr && PS_IS_playing (bman.players[p].state)) {
pl = &bman.players[p];
player_ilness_loop (p);
}
}; };
/* create a giving number of ai players */
void single_create_ai () { void
single_create_ai (int players)
{
int p; int p;
int count;
_player *pl; _player *pl;
for (count = 0; count < players; count++) {
/* find free players */ /* find free players */
for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++) for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state))) if (!(PS_IS_used (bman.players[p].state))) {
pl = &bman.players[p]; pl = &bman.players[p];
pl->state |= PSF_used + PSF_alife + PSF_playing;
player_set_gfx (pl, s_random (MAX_PLAYERS));
}
if (pl == NULL) if (pl == NULL)
return; return;
}
};
void single_playergame () {
int p;
/* delete player from the game */
for (p = 0; p < MAX_PLAYERS; p++)
bman.players[p].state = 0;
single_create_ai (4);
single_game_new ();
gfx_game_init ();
game_loop ();
gfx_game_shutdown ();
}; };
Loading…
Cancel
Save