Single Player is now working fine and have got a menu

origin
stpohle 23 years ago
parent 9d3f49af37
commit eeec4c4264

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.31 2003/05/30 19:57:20 patty21 Exp $ */ /* $Id: bomberclone.h,v 1.32 2003/06/01 20:34:47 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -161,6 +161,8 @@ struct __bomberclone {
unsigned char firewall; unsigned char firewall;
unsigned char notifygamemaster; unsigned char notifygamemaster;
unsigned char askplayername; // ask player for name at startup unsigned char askplayername; // ask player for name at startup
unsigned char ai_players; // number of ai players
signed char debug; // 0 = off 1 = on signed char debug; // 0 = off 1 = on
} typedef _bomberclone; } typedef _bomberclone;
@ -256,6 +258,7 @@ extern void single_game_new ();
extern void single_create_ai (int players); extern void single_create_ai (int players);
extern void single_loop(); extern void single_loop();
extern void single_playergame (); extern void single_playergame ();
extern void single_menu ();
extern int ai_choosedir (int dir, int nearbomb, int oldpos); extern int ai_choosedir (int dir, int nearbomb, int oldpos);
extern int ai_invertdir (int dir); extern int ai_invertdir (int dir);
extern int ai_checkpos (_player * pl, _point * pos); extern int ai_checkpos (_player * pl, _point * pos);

@ -53,6 +53,7 @@ game_init (int argc, char **argv)
bman.fieldpath[0] = 0; bman.fieldpath[0] = 0;
bman.random_map = 2; bman.random_map = 2;
bman.firewall = 0; bman.firewall = 0;
bman.ai_players = 1;
snd.inited = 0; snd.inited = 0;
init_map_tileset(); init_map_tileset();
@ -168,6 +169,9 @@ ReadConfig ()
if (!strcmp (keyword, "firewall")) { if (!strcmp (keyword, "firewall")) {
bman.firewall = atoi (value); bman.firewall = atoi (value);
} }
if (!strcmp (keyword, "ai_players")) {
bman.ai_players = atoi (value);
}
if (!strcmp (keyword, "fieldsizex")) { if (!strcmp (keyword, "fieldsizex")) {
bman.fieldsize.x = atoi (value); bman.fieldsize.x = atoi (value);
} }
@ -234,6 +238,7 @@ WriteConfig ()
fprintf (config, "tileset=%s\n", gfx.tileset); fprintf (config, "tileset=%s\n", gfx.tileset);
fprintf (config, "fieldpath=%s\n", bman.fieldpath); fprintf (config, "fieldpath=%s\n", bman.fieldpath);
fprintf (config, "firewall=%d\n", bman.firewall); fprintf (config, "firewall=%d\n", bman.firewall);
fprintf (config, "ai_players=%d\n", bman.ai_players);
fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x); fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x);
fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y); fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y);
fprintf (config, "notify=%d\n", bman.notifygamemaster); fprintf (config, "notify=%d\n", bman.notifygamemaster);

@ -218,7 +218,7 @@ game_loop ()
/* 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 (bman.players_nr < 2) if ((bman.players_nr < 2 && (GT_MP_PTP || (bman.gametype == GT_single && bman.ai_players > 0))) || (bman.gametype == GT_single && bman.ai_players == 0 && bman.players_nr < 1))
gameovertimeout--; gameovertimeout--;
if (gameovertimeout <= 0) { if (gameovertimeout <= 0) {

@ -40,7 +40,7 @@ main (int argc, char **argv)
switch (menuselect) { switch (menuselect) {
case (0) : // Singleplayer case (0) : // Singleplayer
single_playergame (); single_menu ();
break; break;
case (1) : // Multiplayer case (1) : // Multiplayer
netmenu(); netmenu();

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.29 2003/06/01 20:18:27 stpohle Exp $ */ /* $Id: single.c,v 1.30 2003/06/01 20:34:47 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -626,7 +626,7 @@ single_playergame ()
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
bman.players[p].state = 0; bman.players[p].state = 0;
single_create_ai (1); single_create_ai (bman.ai_players);
single_game_new (); single_game_new ();
gfx_game_init (); gfx_game_init ();
game_loop (); game_loop ();
@ -693,3 +693,41 @@ single_loop ()
move_player (p); move_player (p);
} }
}; };
/* singleplayer menü with some options you can make */
void single_menu () {
int menuselect = 0;
_menu menu[] = {
{1, "Start Game"},
{2, "Number Of Players"},
{3, "Map Option"},
{4, "Return To Main Menu"},
{-1, ""}
};
while (menuselect != -1 && bman.state != GS_quit) {
sprintf (menu[1].text, "%d AI Player", bman.ai_players);
menuselect = menu_loop ("Single Player", menu, menuselect);
switch (menuselect) {
case (0): // Start Game
single_playergame ();
break;
case (1): // Change number of Player
bman.ai_players++;
if (bman.ai_players >= MAX_PLAYERS) {
if (debug)
bman.ai_players = 0; // null players with debugging on
else
bman.ai_players = 1;
}
break;
case (2): // Map Options
mapmenu();
break;
case (3):
menuselect = -1;
break;
}
}
};
Loading…
Cancel
Save