facb42a3edcc0ef496111663d294d319a422288c
[supertux.git] / src / supertux.cpp
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #include <sys/types.h>
22 #include <ctype.h>
23
24 #include "defines.h"
25 #include "globals.h"
26 #include "setup.h"
27 #include "intro.h"
28 #include "title.h"
29 #include "gameloop.h"
30 #include "leveleditor.h"
31 #include "screen.h"
32 #include "worldmap.h"
33 #include "resources.h"
34 #include "texture.h"
35 #include "tile.h"
36
37 int main(int argc, char * argv[])
38 {
39   st_directory_setup();
40   parseargs(argc, argv);
41   
42   st_audio_setup();
43   st_video_setup();
44   st_joystick_setup();
45   st_general_setup();
46   st_menu();
47   loadshared();
48
49   if (launch_worldmap_mode)
50     {
51       WorldMapNS::WorldMap worldmap;
52       worldmap.display();
53     }
54   else if (level_startup_file)
55     {
56       GameSession session(level_startup_file, 1, ST_GL_LOAD_LEVEL_FILE);
57       session.run();
58     }
59   else
60     {  
61       title();
62     }
63   
64   clearscreen(0, 0, 0);
65   updatescreen();
66
67   unloadshared();
68   st_general_free();
69   TileManager::destroy_instance();
70 #ifdef DEBUG
71   Surface::debug_check();
72 #endif
73   st_shutdown();
74   
75   return 0;
76 }