3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
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.
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.
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 02111-1307, USA.
20 #include "app/globals.h"
26 #include "resources.h"
27 #include "special/sprite_manager.h"
28 #include "audio/sound_manager.h"
29 #include "app/setup.h"
31 #include "gui/button.h"
33 Surface* img_waves[3];
38 Surface* img_cloud[2][4];
39 Surface* img_distro[4];
43 Menu* options_menu = 0;
44 Menu* options_keys_menu = 0;
45 Menu* options_joystick_menu = 0;
46 Menu* highscore_menu = 0;
47 Menu* load_game_menu = 0;
48 Menu* save_game_menu = 0;
49 Menu* contrib_menu = 0;
50 Menu* contrib_subset_menu = 0;
52 MusicRef herring_song;
53 MusicRef level_end_song;
55 SpriteManager* sprite_manager = 0;
56 SoundManager* sound_manager = 0;
58 char * soundfilenames[NUM_SOUNDS] = {
60 "/sounds/bigjump.wav",
63 "/sounds/invincible.wav",
68 "/sounds/ricochet.wav",
69 "/sounds/bump-upgrade.wav",
70 "/sounds/upgrade.wav",
72 "/sounds/fire-flower.wav",
77 "/sounds/explosion.wav",
79 "/sounds/fireworks.wav"
88 Font* white_small_text;
91 /* Load graphics/sounds shared between all levels: */
95 /* Load global images: */
96 gold_text = new Font(datadir + "/images/fonts/gold.png", Font::TEXT, 16,18);
97 blue_text = new Font(datadir + "/images/fonts/blue.png", Font::TEXT, 16,18,3);
98 white_text = new Font(datadir + "/images/fonts/white.png",
100 gray_text = new Font(datadir + "/images/fonts/gray.png",
102 white_small_text = new Font(datadir + "/images/fonts/white-small.png",
104 white_big_text = new Font(datadir + "/images/fonts/white-big.png",
105 Font::TEXT, 20,22, 3);
106 yellow_nums = new Font(datadir + "/images/fonts/numbers.png",
109 Menu::default_font = white_text;
110 Menu::active_font = blue_text;
111 Menu::deactive_font = gray_text;
112 Menu::label_font = white_big_text;
113 Menu::field_font = gold_text;
115 Button::info_font = white_small_text;
119 sprite_manager = new SpriteManager(datadir + "/images/supertux.strf");
122 smalltux_star = sprite_manager->load("smalltux-star");
123 bigtux_star = sprite_manager->load("bigtux-star");
124 smalltux_gameover = sprite_manager->load("smalltux-gameover");
127 for (int i = 0; i < GROWING_FRAMES; i++)
129 sprintf(img_name, "%s/images/shared/tux-grow-left-%i.png", datadir.c_str(), i+1);
130 growingtux_left[i] = new Surface(img_name, true);
132 sprintf(img_name, "%s/images/shared/tux-grow-right-%i.png", datadir.c_str(), i+1);
133 growingtux_right[i] = new Surface(img_name, true);
136 small_tux = new TuxBodyParts();
137 small_tux->head = NULL;
138 small_tux->body = sprite_manager->load("small-tux-body");
139 small_tux->arms = sprite_manager->load("small-tux-arms");
140 small_tux->feet = NULL;
142 big_tux = new TuxBodyParts();
143 big_tux->head = sprite_manager->load("big-tux-head");
144 big_tux->body = sprite_manager->load("big-tux-body");
145 big_tux->arms = sprite_manager->load("big-tux-arms");
146 big_tux->feet = sprite_manager->load("big-tux-feet");
148 fire_tux = new TuxBodyParts();
149 fire_tux->head = sprite_manager->load("big-fire-tux-head");
150 fire_tux->body = sprite_manager->load("big-tux-body");
151 fire_tux->arms = sprite_manager->load("big-tux-arms");
152 fire_tux->feet = sprite_manager->load("big-tux-feet");
154 ice_tux = new TuxBodyParts();
155 ice_tux->head = sprite_manager->load("big-tux-head");
156 ice_tux->body = sprite_manager->load("big-tux-body");
157 ice_tux->arms = sprite_manager->load("big-tux-arms");
158 ice_tux->feet = sprite_manager->load("big-tux-feet");
161 img_water = new Surface(datadir + "/images/shared/water.png", false);
163 img_waves[0] = new Surface(datadir + "/images/shared/waves-0.png",
166 img_waves[1] = new Surface(datadir + "/images/shared/waves-1.png",
170 img_waves[2] = new Surface(datadir + "/images/shared/waves-2.png",
176 img_pole = new Surface(datadir + "/images/shared/pole.png", true);
177 img_poletop = new Surface(datadir + "/images/shared/poletop.png",
183 img_flag[0] = new Surface(datadir + "/images/shared/flag-0.png",
185 img_flag[1] = new Surface(datadir + "/images/shared/flag-1.png",
191 img_cloud[0][0] = new Surface(datadir + "/images/shared/cloud-00.png",
194 img_cloud[0][1] = new Surface(datadir + "/images/shared/cloud-01.png",
197 img_cloud[0][2] = new Surface(datadir + "/images/shared/cloud-02.png",
200 img_cloud[0][3] = new Surface(datadir + "/images/shared/cloud-03.png",
204 img_cloud[1][0] = new Surface(datadir + "/images/shared/cloud-10.png",
207 img_cloud[1][1] = new Surface(datadir + "/images/shared/cloud-11.png",
210 img_cloud[1][2] = new Surface(datadir + "/images/shared/cloud-12.png",
213 img_cloud[1][3] = new Surface(datadir + "/images/shared/cloud-13.png",
226 // load the door object graphics:
227 door = sprite_manager->load("door");
228 for (int i = 0; i < DOOR_OPENING_FRAMES; i++)
230 sprintf(img_name, "%s/images/shared/door-%i.png", datadir.c_str(), i+1);
231 door_opening[i] = new Surface(img_name, true);
235 img_distro[0] = new Surface(datadir + "/images/tilesets/coin1.png",
238 img_distro[1] = new Surface(datadir + "/images/tilesets/coin2.png",
241 img_distro[2] = new Surface(datadir + "/images/tilesets/coin3.png",
244 img_distro[3] = new Surface(datadir + "/images/tilesets/coin2.png",
250 tux_life = new Surface(datadir + "/images/shared/tux-life.png",
255 /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound"
256 // initialize sounds[i] with the correct pointer's value:
257 // NULL or something else. And it will be dangerous to
258 // play with not-initialized pointers.
259 // This is also true with if (use_music)
260 Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :)
262 for (i = 0; i < NUM_SOUNDS; i++)
264 ()->add_sound(SoundManager::get
265 ()->load_sound(datadir + soundfilenames[i]),i);
268 herring_song = SoundManager::get
269 ()->load_music(datadir + "/music/SALCON.MOD");
270 level_end_song = SoundManager::get
271 ()->load_music(datadir + "/music/leveldone.mod");
274 /* Free shared data: */
275 void unloadshared(void)
277 /* Free global images: */
282 delete white_small_text;
283 delete white_big_text;
292 for (i = 0; i < 3; i++)
298 for (i = 0; i < 2; i++)
301 for (i = 0; i < 4; i++)
303 delete img_distro[i];
304 delete img_cloud[0][i];
305 delete img_cloud[1][i];
315 for (int i = 0; i < GROWING_FRAMES; i++)
317 delete growingtux_left[i];
318 delete growingtux_right[i];
323 for (int i = 0; i < DOOR_OPENING_FRAMES; i++)
324 delete door_opening[i];
326 delete sprite_manager;