dungeon_crawler
view prototype/src/cfg.cc @ 21:0588f8a1a351
converting LIGHT meshes to lights
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 21 Aug 2012 06:33:36 +0300 |
parents | |
children | 527fede30057 |
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "cfg.h"
6 Config cfg;
8 Config::Config()
9 {
10 width = 800;
11 height = 600;
12 stereo = false;
13 level_file = "0.level";
14 tileset_file = "default.tileset";
15 }
17 bool Config::parse_args(int argc, char **argv)
18 {
19 for(int i=1; i<argc; i++) {
20 if(strcmp(argv[i], "-s") == 0) {
21 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
22 fprintf(stderr, "-s must be followed by <width>x<height>\n");
23 return false;
24 }
25 } else if(strcmp(argv[i], "-stereo") == 0) {
26 stereo = true;
27 } else if(strcmp(argv[i], "-level") == 0) {
28 level_file = argv[++i];
29 } else if(strcmp(argv[i], "-tileset") == 0) {
30 tileset_file = argv[++i];
31 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
32 printf("Usage: %s [options]\n", argv[0]);
33 printf(" -s WxH window size (resolution)\n");
34 printf(" -level <filename> specify which level file to load\n");
35 printf(" -tileset <filename> specify which tileset to use\n");
36 printf(" -stereo enable stereoscopic rendering\n");
37 printf(" -h/-help print usage information and exit\n");
38 exit(0);
40 } else {
41 fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
42 return false;
43 }
44 }
45 return true;
46 }