dungeon_crawler
diff prototype/src/main.cc @ 5:252a00508411
more stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 12 Aug 2012 07:07:57 +0300 |
parents | 96de911d05d4 |
children | 8fb37db44fd8 |
line diff
1.1 --- a/prototype/src/main.cc Sat Aug 11 05:44:52 2012 +0300 1.2 +++ b/prototype/src/main.cc Sun Aug 12 07:07:57 2012 +0300 1.3 @@ -4,19 +4,31 @@ 1.4 #include "opengl.h" 1.5 #include "level.h" 1.6 #include "camera.h" 1.7 +#include "datapath.h" 1.8 +#include "tileset.h" 1.9 1.10 +bool init(); 1.11 +void cleanup(); 1.12 void disp(); 1.13 void reshape(int x, int y); 1.14 void keyb(unsigned char key, int x, int y); 1.15 void mouse(int bn, int state, int x, int y); 1.16 void motion(int x, int y); 1.17 1.18 +static TileSet *tileset; 1.19 static Level *level; 1.20 static OrbitCamera cam; 1.21 1.22 +static const char *level_file = "0.level"; 1.23 + 1.24 int main(int argc, char **argv) 1.25 { 1.26 glutInit(&argc, argv); 1.27 + 1.28 + if(argc > 1) { 1.29 + level_file = argv[1]; 1.30 + } 1.31 + 1.32 glutInitWindowSize(800, 600); 1.33 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | GLUT_MULTISAMPLE); 1.34 glutCreateWindow("prototype"); 1.35 @@ -29,6 +41,15 @@ 1.36 1.37 glewInit(); 1.38 1.39 + if(!init()) { 1.40 + return 1; 1.41 + } 1.42 + 1.43 + glutMainLoop(); 1.44 +} 1.45 + 1.46 +bool init() 1.47 +{ 1.48 glEnable(GL_LIGHTING); 1.49 glEnable(GL_LIGHT0); 1.50 float ldir[] = {-1, 1, 2, 0}; 1.51 @@ -39,12 +60,21 @@ 1.52 glEnable(GL_CULL_FACE); 1.53 glEnable(GL_MULTISAMPLE); 1.54 1.55 + add_data_path("data"); 1.56 + 1.57 + // load a tileset 1.58 + tileset = new TileSet; 1.59 + if(!tileset->load(datafile_path("default.tileset"))) { 1.60 + return false; 1.61 + } 1.62 + set_active_tileset(tileset); 1.63 + 1.64 level = new Level; 1.65 - if(!level->load("foobar")) { 1.66 - return 1; 1.67 + if(!level->load(datafile_path(level_file))) { 1.68 + return false; 1.69 } 1.70 1.71 - glutMainLoop(); 1.72 + return true; 1.73 } 1.74 1.75 void disp()