First Steps for Single Player mode

origin
stpohle 23 years ago
parent e766605b61
commit ea434d8194

@ -29,7 +29,8 @@ bomberclone_SOURCES = \
multiwait.c \
chat.h \
keybinput.h \
keybinput.c
keybinput.c \
single.c
## bomberclone_LDADD =

@ -111,7 +111,8 @@ bomberclone_SOURCES = \
multiwait.c \
chat.h \
keybinput.h \
keybinput.c
keybinput.c \
single.c
subdir = src
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -125,7 +126,8 @@ am_bomberclone_OBJECTS = main.$(OBJEXT) bomb.$(OBJEXT) debug.$(OBJEXT) \
game.$(OBJEXT) netmenu.$(OBJEXT) network.$(OBJEXT) \
udp.$(OBJEXT) menu.$(OBJEXT) field.$(OBJEXT) sysfunc.$(OBJEXT) \
configuration.$(OBJEXT) pkgcache.$(OBJEXT) gamesrv.$(OBJEXT) \
chat.$(OBJEXT) multiwait.$(OBJEXT) keybinput.$(OBJEXT)
chat.$(OBJEXT) multiwait.$(OBJEXT) keybinput.$(OBJEXT) \
single.$(OBJEXT)
bomberclone_OBJECTS = $(am_bomberclone_OBJECTS)
bomberclone_LDADD = $(LDADD)
bomberclone_DEPENDENCIES =
@ -146,7 +148,8 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
@AMDEP_TRUE@ $(DEPDIR)/multiwait.Po $(DEPDIR)/netmenu.Po \
@AMDEP_TRUE@ $(DEPDIR)/network.Po $(DEPDIR)/packets.Po \
@AMDEP_TRUE@ $(DEPDIR)/pkgcache.Po $(DEPDIR)/player.Po \
@AMDEP_TRUE@ $(DEPDIR)/sysfunc.Po $(DEPDIR)/udp.Po
@AMDEP_TRUE@ $(DEPDIR)/single.Po $(DEPDIR)/sysfunc.Po \
@AMDEP_TRUE@ $(DEPDIR)/udp.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
@ -218,6 +221,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/packets.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pkgcache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/player.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/single.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sysfunc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/udp.Po@am__quote@

@ -144,9 +144,8 @@ extern int debug;
// Game routines..
extern void game_draw_info ();
extern void game_loop ();
extern void single_game_new ();
extern void multi_new_game ();
extern void game_end ();
extern void game_set_playerposition();
// everything is declared in field.c
extern void draw_field ();
@ -209,5 +208,10 @@ extern void d_playerdetail (char *head);
extern void d_gamedetail (char *head);
extern void d_printf (char *fmt,...);
// single.c
extern void single_game_new ();
extern void single_create_ai ();
extern void single_loop();
#endif

@ -170,6 +170,8 @@ game_loop ()
if (bman.gametype != GT_single)
network_loop ();
else
single_loop ();
/* this will even set the variable "bman.player_nr"
to let us know how much Players are still left */
@ -211,70 +213,9 @@ game_loop ()
};
void
single_game_new ()
{
int p,
i;
// set players on field 1,1
for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = 1 << 8;
bman.players[p].pos.y = 1 << 8;
bman.players[p].state = 0;
// reset bombs
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
}
for (i = 0; i < PI_max; i++)
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
}
bman.p_nr = 0;
bman.players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], 0);
bman.last_ex_nr = 1;
field_new ();
bman.players_nr_s = 1;
bman.players_nr = 1;
bman.gametype = GT_single;
bman.state = GS_running;
};
/*
this routine is only for the server.
after this the data should be transfered to the other clients.
*/
void
multi_new_game ()
{
int p,
i,
j,
dx,
dy,
mx,
my,
dist;
// set players thier fields
for (i = 0; i < MAX_PLAYERS; i++)
bman.players[i].pos.y = bman.players[i].pos.x = -1;
bman.players_nr = 0;
void game_set_playerposition () {
int p, dist, i,j , mx, my, dx, dy;
p = 50;
dist = 8;
while (p == 50) {
@ -304,49 +245,6 @@ multi_new_game ()
p++;
}
}
bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = bman.players[p].pos.x << 8;
bman.players[p].pos.y = bman.players[p].pos.y << 8;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
if (bman.players[p].gfx_nr == -1) {
bman.players[p].gfx = NULL;
bman.players[p].state &= (0xff - (PSF_alife + PSF_playing));
}
else {
bman.players[p].state |= PSF_alife + PSF_playing;
bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr];
}
}
else
bman.players[p].state = 0;
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
// reset bombs
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
}
}
field_new ();
bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player
bman.last_ex_nr = 1;
};
@ -372,3 +270,4 @@ game_end ()
bman.players[i].state = 0;
}

@ -46,6 +46,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 ();

@ -406,7 +406,7 @@ net_new_gamedata ()
Uint8 *keys;
Uint32 downtimestamp = 0;
multi_new_game (); // we do it to for the clients 'cause we need to reset the clients
net_host_new_game (); // we do it to for the clients 'cause we need to reset the clients
draw_logo ();
if (GT_MP_PTPM)
@ -708,3 +708,64 @@ void net_game_send_ill (int p_nr) {
send_ill (&bman.players[i].net.addr, p_nr, &bman.players[p_nr]);
};
/*
this routine is only for the server.
after this the data should be transfered to the other clients.
*/
void
net_host_new_game ()
{
int p,
i;
// set players thier fields
for (i = 0; i < MAX_PLAYERS; i++)
bman.players[i].pos.y = bman.players[i].pos.x = -1;
bman.players_nr = 0;
game_set_playerposition();
bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = bman.players[p].pos.x << 8;
bman.players[p].pos.y = bman.players[p].pos.y << 8;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
if (bman.players[p].gfx_nr == -1) {
bman.players[p].gfx = NULL;
bman.players[p].state &= (0xff - (PSF_alife + PSF_playing));
}
else {
bman.players[p].state |= PSF_alife + PSF_playing;
bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr];
}
}
else
bman.players[p].state = 0;
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
// reset bombs
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
}
}
field_new ();
bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player
bman.last_ex_nr = 1;
};

@ -69,6 +69,7 @@ extern void net_send_players ();
extern int net_check_timeout (int pl_nr);
extern void net_dyn_pkgoption ();
extern void net_send_chat (char *text, signed char notigamesrv);
extern void net_host_new_game ();
// multiwait.c

@ -0,0 +1,66 @@
/* single player */
#include "basic.h"
#include "bomberclone.h"
void
single_game_new (int ai_players)
{
int p,
i;
// set players on field 1,1
for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].pos.x = 1 << 8;
bman.players[p].pos.y = 1 << 8;
bman.players[p].state = 0;
// reset bombs
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;
}
for (i = 0; i < PI_max; i++)
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;
bman.players[p].d = 0;
}
bman.p_nr = 0;
bman.players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], 0);
bman.last_ex_nr = 1;
field_new ();
bman.players_nr_s = 1;
bman.players_nr = 1;
bman.gametype = GT_single;
bman.state = GS_running;
};
void single_loop () {
};
void single_create_ai () {
int p;
_player *pl;
/* find free players */
for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state)))
pl = &bman.players[p].state;
if (pl == NULL)
return;
};
};
Loading…
Cancel
Save