3 Copyright (C) 2003 Nuno Subtil
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 static const char cvsid
[] =
21 "$Id: main.c,v 1.60 2003/11/27 22:11:57 nsubtil Exp $";
44 #include "oglconsole.h"
46 extern struct game
* current_game
;
49 * TODO: Rename function. Need to look around code where it calls
50 * SDL_Quit() and exit and see if we can call this instead in
61 static int parse_resolution(char *res
, int *w
, int *h
, int *bpp
)
66 snprintf(res_copy
, sizeof(res_copy
)-1, "%s", res
);
67 p
= strtok(res_copy
, "x");
74 p
= strtok(NULL
, "x");
81 p
= strtok(NULL
, "x");
91 printf("Could not parse resolution '%s'\n", res
);
96 /* TODO: rewrite parsing routines here */
97 /* TODO: Add 'map' command to change maps */
98 static void console_input(OGLCONSOLE_Console console
, char *cmd
)
100 int width
, height
, x
;
102 if (!strncmp(cmd
, "quit", 4) ||
103 !strncmp(cmd
, "exit", 4)) {
107 if (!strncmp(cmd
, "res ", 4)) {
108 if (parse_resolution((cmd
+4), &width
, &height
, &x
) != 0) {
109 con_printf("usage: res <resolution> e.g. 640x480\n");
112 screen_set_resolution(width
, height
);
113 screen_switch_resolution();
114 OGLCONSOLE_InitText(console
, width
, height
);
118 if (!strncmp(cmd
, "score", 5)) {
120 con_printf("Start playing, first...\n");
123 if (!current_game
->players
) {
124 con_printf("But, there are no players?\n");
127 for (x
= 0; x
< current_game
->n_players
; x
++) {
128 con_printf("Player %d: %d points, %d lives\n", x
+1,
129 current_game
->players
[x
].score
,
130 current_game
->players
[x
].lives
);
135 OGLCONSOLE_Output(console
, "Invalid command: %s\n", cmd
);
139 int main(int argc
, char **argv
)
142 int width
= 800, height
= 600, bpp
= 32, fullscreen
= 0;
143 int enable_sound
= 1;
145 while ((opt
= getopt(argc
, argv
, "fwr:q")) != EOF
) {
157 if (parse_resolution(optarg
, &width
, &height
,
160 printf("Set resolution to %dx%dx%d\n",
164 fprintf(stderr
, "Invalid command line option: %c\n",
174 render_reshape_window(screen->w, screen->h);
177 srand(SDL_GetTicks());
179 screen_init(fullscreen
, width
, height
, bpp
);
181 audio_init(enable_sound
);
185 object_read_file("gfx/pacman-moving.3d", &last_update);
186 object_read_file("gfx/pacman-dying.3d", &last_update);
187 object_read_file("gfx/pacman-stopped.3d", &last_update);
188 object_read_file("gfx/ghost-green-moving.3d", &last_update);
189 object_read_file("gfx/ghost-green-dying.3d", &last_update);
190 object_read_file("gfx/ghost-green-returning.3d", &last_update);
193 if(argc
> 1 && strcmp(argv
[1], "--server") == 0)
196 if(argc
> 1 && strcmp(argv
[1], "--connect") == 0)
197 net_client_init(argv
[2]);
200 OGLCONSOLE_EnterKey(console_input
);