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 */
#ifndef _BOMBERCLONE_H_
@ -192,7 +192,7 @@ extern void player_calcstep (_player * pl);
extern void player_calcpos ();
extern void player_set_ilness (_player *p, int t);
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_set_gfx (_player *p, signed char gfx_nr);
@ -231,8 +231,9 @@ extern void d_printf (char *fmt,...);
// single.c
extern void single_game_new ();
extern void single_create_ai ();
extern void single_create_ai (int players);
extern void single_loop();
extern void single_playergame ();
// mapmenu.c
extern void map_random ();

@ -11,7 +11,8 @@
extern int UpdateRects_nr;
static Uint32 timediff;
static Uint32 timediff,
timediff1;
void
game_draw_info ()
@ -21,14 +22,19 @@ game_draw_info ()
j;
char text[255];
char scrtext[255];
SDL_Rect src, dest;
SDL_Rect src,
dest;
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;
/* draw Player names */
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++)
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;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n);
@ -76,7 +88,6 @@ game_draw_info ()
draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready)
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);
@ -91,7 +102,7 @@ game_draw_info ()
text[strlen (text)] = ']';
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);
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);
@ -111,7 +122,6 @@ game_loop ()
Uint8 *keys;
int done = 0;
Uint32 timeloop1;
int move=0;
int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key
@ -126,6 +136,7 @@ game_loop ()
d_gamedetail ("GAME START");
draw_players ();
while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if (SDL_PollEvent (&event) != 0)
switch (event.type) {
@ -176,10 +187,13 @@ game_loop ()
bman.state = GS_startup;
done = 1;
}
move=bman.players[bman.p_nr].m;
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)
move_player ();
@ -192,19 +206,14 @@ game_loop ()
/* this will even set the variable "bman.player_nr"
to let us know how much Players are still left */
if (bomb_loop () || move || GT_MP_PTP) draw_players ();
move=0;
bomb_loop ();
draw_players ();
game_draw_info ();
gfx_UpdateRects ();
/* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */
if ((GT_MP_PTPM) && 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))
if (bman.players_nr < 2)
gameovertimeout--;
if (gameovertimeout <= 0) {
@ -221,6 +230,7 @@ game_loop ()
timeloop1 = SDL_GetTicks ();
}
timediff1 = timeloop1 - timestamp;
timestamp = timeloop1;
}
@ -252,5 +262,3 @@ game_end ()
if ((bman.players[i].state & PSF_used) == 0)
bman.players[i].state = 0;
}

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

@ -60,7 +60,6 @@ restore_players_screen ()
x,
xs,
xe,
y,
ys,
ye;
@ -91,7 +90,8 @@ restore_players_screen ()
for (y = ys; y <= ye; 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 _x = p->pos.x & 255;
int _y = p->pos.y & 255;
int ft,i;
int ft,
i;
/* Get the right field position */
if (_x > 128)
@ -118,20 +119,30 @@ player_check_powerup (_player * p)
if (ft == FT_mixed) {
i = s_random (6);
switch (i) {
case 0:ft=FT_bomb;break;
case 1:ft=FT_fire;break;
case 2:ft=FT_shoe;break;
case 0:
ft = FT_bomb;
break;
case 1:
ft = FT_fire;
break;
case 2:
ft = FT_shoe;
break;
case 3:
case 4:
case 5:ft=FT_death;break;
case 5:
ft = FT_death;
break;
}
}
switch (ft) {
/* we found a bomb powerup */
case FT_bomb:
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0)
{p->bombs_n++;bman.updatestatusbar=1;}
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0) {
p->bombs_n++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -139,8 +150,10 @@ player_check_powerup (_player * p)
/* we found a fire powerup */
case FT_fire:
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0)
{p->range++;bman.updatestatusbar=1;}
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) {
p->range++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -148,8 +161,10 @@ player_check_powerup (_player * p)
/* we found a shoe powerup */
case FT_shoe:
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0)
{p->speed *= SPEEDMUL;bman.updatestatusbar=1;}
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) {
p->speed *= SPEEDMUL;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -159,6 +174,7 @@ player_check_powerup (_player * p)
case FT_death:
player_set_ilness (p, -1);
bman.updatestatusbar = 1;
if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr);
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->dead_by = dead_by;
if (GT_MP_PTP)
net_game_send_player (bman.p_nr);
};
@ -428,11 +445,14 @@ player_animation (_player * player)
int
dead_playerani ()
{
int i,b=0;
int i,
b = 0;
for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_dead (bman.players[i].state))
{player_animation (&bman.players[i]);b++;}
if (PS_IS_dead (bman.players[i].state)) {
player_animation (&bman.players[i]);
b++;
}
return b;
};
@ -505,7 +525,7 @@ player_calcpos ()
void
player_ilness_loop ()
player_ilness_loop (int pl_nr)
{
_player *p;
int type,
@ -516,8 +536,9 @@ player_ilness_loop ()
int pl[MAX_PLAYERS + 1];
/* do the illness for the network players */
if (GT_MP_PTP) {
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];
for (type = 0; type < PI_max; type++)
if (p->ill[type].to > 0) {
@ -531,13 +552,13 @@ player_ilness_loop ()
}
}
}
}
/* 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);
for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++)
if (pl[i] != bman.p_nr) {
if (pl[i] != pl_nr) {
send = 0;
for (type = 0; type < PI_max; type++) {
if (bman.players[pl[i]].ill[type].to > p->ill[type].to) {
@ -548,11 +569,11 @@ player_ilness_loop ()
send = 1;
}
}
if (send != 0)
net_game_send_ill (bman.p_nr);
if (send != 0 && GT_MP_PTP)
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++)
if (p->ill[type].to > 0) {
p->ill[type].to--;
@ -669,6 +690,7 @@ player_clear_ilness (_player * p, int type)
}
p->ill[type].to = 0;
if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr);
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 */
#include "basic.h"
#include "bomberclone.h"
void
single_game_new (int ai_players)
single_game_new ()
{
int p,
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++) {
bman.players[p].pos.x = -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;
// reset bombs
@ -32,35 +41,73 @@ single_game_new (int ai_players)
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;
player_set_gfx (&bman.players[bman.p_nr], 0);
bman.last_ex_nr = 1;
init_map_tileset ();
bman.players_nr_s = 1;
bman.players_nr = 1;
bman.gametype = GT_single;
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);
}
};
void single_create_ai () {
/* create a giving number of ai players */
void
single_create_ai (int players)
{
int p;
int count;
_player *pl;
for (count = 0; count < players; count++) {
/* find free players */
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->state |= PSF_used + PSF_alife + PSF_playing;
player_set_gfx (pl, s_random (MAX_PLAYERS));
}
if (pl == NULL)
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