3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2004 Matthias Braun <matze@braunis.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.
27 #include "app/globals.h"
29 #include "utils/lispreader.h"
34 #include "background.h"
35 #include "particlesystem.h"
38 #include "audio/sound_manager.h"
40 #include "resources.h"
41 #include "interactive_object.h"
44 Sector* Sector::_current = 0;
47 : gravity(10), player(0), solids(0), background(0), camera(0),
48 currentmusic(LEVEL_MUSIC)
50 song_title = "Mortimers_chipdisko.mod";
51 player = new Player();
57 for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end();
61 for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
70 Sector::parse(LispReader& lispreader)
74 for(lisp_object_t* cur = lispreader.get_lisp(); !lisp_nil_p(cur);
75 cur = lisp_cdr(cur)) {
76 std::string token = lisp_symbol(lisp_car(lisp_car(cur)));
77 // FIXME: doesn't handle empty data
78 lisp_object_t* data = lisp_car(lisp_cdr(lisp_car(cur)));
79 LispReader reader(lisp_cdr(lisp_car(cur)));
82 name = lisp_string(data);
83 } else if(token == "gravity") {
84 gravity = lisp_real(data);
85 } else if(token == "music") {
86 song_title = lisp_string(data);
88 } else if(token == "camera") {
90 std::cerr << "Warning: More than 1 camera defined in sector.\n";
93 camera = new Camera(this);
96 } else if(token == "background") {
97 background = new Background(reader);
98 add_object(background);
99 } else if(token == "spawn-points") {
100 SpawnPoint* sp = new SpawnPoint;
101 reader.read_string("name", sp->name);
102 reader.read_float("x", sp->pos.x);
103 reader.read_float("y", sp->pos.y);
104 spawnpoints.push_back(sp);
105 } else if(token == "tilemap") {
106 TileMap* tilemap = new TileMap(reader);
109 if(tilemap->is_solid()) {
111 std::cerr << "Warning multiple solid tilemaps in sector.\n";
116 } else if(badguykind_from_string(token) != BAD_INVALID) {
117 add_object(new BadGuy(badguykind_from_string(token), reader));
118 } else if(token == "trampoline") {
119 add_object(new Trampoline(reader));
120 } else if(token == "flying-platform") {
121 add_object(new FlyingPlatform(reader));
122 } else if(token == "particles-snow") {
123 SnowParticleSystem* partsys = new SnowParticleSystem();
124 partsys->parse(reader);
126 } else if(token == "particles-clouds") {
127 CloudParticleSystem* partsys = new CloudParticleSystem();
128 partsys->parse(reader);
130 } else if(token == "door") {
131 add_object(new Door(reader));
133 std::cerr << "Unknown object type '" << token << "'.\n";
138 std::cerr << "sector '" << name << "' does not contain a camera.\n";
139 camera = new Camera(this);
143 throw std::runtime_error("sector does not contain a solid tile layer.");
147 Sector::parse_old_format(LispReader& reader)
152 reader.read_float("gravity", gravity);
154 std::string backgroundimage;
155 reader.read_string("background", backgroundimage);
157 reader.read_float("bkgd_speed", bgspeed);
160 Color bkgd_top, bkgd_bottom;
161 int r = 0, g = 0, b = 128;
162 reader.read_int("bkgd_red_top", r);
163 reader.read_int("bkgd_green_top", g);
164 reader.read_int("bkgd_blue_top", b);
169 reader.read_int("bkgd_red_bottom", r);
170 reader.read_int("bkgd_green_bottom", g);
171 reader.read_int("bkgd_blue_bottom", b);
173 bkgd_bottom.green = g;
174 bkgd_bottom.blue = b;
176 if(backgroundimage != "") {
177 background = new Background;
178 background->set_image(backgroundimage, bgspeed);
179 add_object(background);
181 background = new Background;
182 background->set_gradient(bkgd_top, bkgd_bottom);
183 add_object(background);
186 std::string particlesystem;
187 reader.read_string("particle_system", particlesystem);
188 if(particlesystem == "clouds")
189 add_object(new CloudParticleSystem());
190 else if(particlesystem == "snow")
191 add_object(new SnowParticleSystem());
193 Vector startpos(100, 170);
194 reader.read_float("start_pos_x", startpos.x);
195 reader.read_float("start_pos_y", startpos.y);
197 SpawnPoint* spawn = new SpawnPoint;
198 spawn->pos = startpos;
199 spawn->name = "main";
200 spawnpoints.push_back(spawn);
202 song_title = "Mortimers_chipdisko.mod";
203 reader.read_string("music", song_title);
206 int width, height = 15;
207 reader.read_int("width", width);
208 reader.read_int("height", height);
210 std::vector<unsigned int> tiles;
211 if(reader.read_int_vector("interactive-tm", tiles)
212 || reader.read_int_vector("tilemap", tiles)) {
213 TileMap* tilemap = new TileMap();
214 tilemap->set(width, height, tiles, LAYER_TILES, true);
219 if(reader.read_int_vector("background-tm", tiles)) {
220 TileMap* tilemap = new TileMap();
221 tilemap->set(width, height, tiles, LAYER_BACKGROUNDTILES, false);
225 if(reader.read_int_vector("foreground-tm", tiles)) {
226 TileMap* tilemap = new TileMap();
227 tilemap->set(width, height, tiles, LAYER_FOREGROUNDTILES, false);
231 // read reset-points (now spawn-points)
233 lisp_object_t* cur = 0;
234 if(reader.read_lisp("reset-points", cur)) {
235 while(!lisp_nil_p(cur)) {
236 lisp_object_t* data = lisp_car(cur);
237 LispReader reader(lisp_cdr(data));
240 if(reader.read_float("x", sp_pos.x) && reader.read_float("y", sp_pos.y))
242 SpawnPoint* sp = new SpawnPoint;
245 spawnpoints.push_back(sp);
255 lisp_object_t* cur = 0;
256 if(reader.read_lisp("objects", cur)) {
257 while(!lisp_nil_p(cur)) {
258 lisp_object_t* data = lisp_car(cur);
259 std::string object_type = lisp_symbol(lisp_car(data));
261 LispReader reader(lisp_cdr(data));
263 if(object_type == "trampoline") {
264 add_object(new Trampoline(reader));
266 else if(object_type == "flying-platform") {
267 add_object(new FlyingPlatform(reader));
270 BadGuyKind kind = badguykind_from_string(object_type);
271 add_object(new BadGuy(kind, reader));
280 camera = new Camera(this);
285 Sector::write(LispWriter& writer)
287 writer.write_string("name", name);
288 writer.write_float("gravity", gravity);
289 writer.write_string("music", song_title);
292 for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
294 SpawnPoint* spawn = *i;
295 writer.start_list("spawn-points");
296 writer.write_string("name", spawn->name);
297 writer.write_float("x", spawn->pos.x);
298 writer.write_float("y", spawn->pos.y);
299 writer.end_list("spawn-points");
303 for(GameObjects::iterator i = gameobjects.begin();
304 i != gameobjects.end(); ++i) {
305 Serializable* serializable = dynamic_cast<Serializable*> (*i);
307 serializable->write(writer);
312 Sector::do_vertical_flip()
314 for(GameObjects::iterator i = gameobjects_new.begin(); i != gameobjects_new.end(); ++i)
316 TileMap* tilemap = dynamic_cast<TileMap*> (*i);
319 tilemap->do_vertical_flip();
322 BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
324 badguy->start_position.y = solids->get_height()*32 - badguy->start_position.y - 32;
325 Trampoline* trampoline = dynamic_cast<Trampoline*> (*i);
327 trampoline->base.y = solids->get_height()*32 - trampoline->base.y - 32;
328 FlyingPlatform* flying_platform = dynamic_cast<FlyingPlatform*> (*i);
330 flying_platform->base.y = solids->get_height()*32 - flying_platform->base.y - 32;
331 Door* door = dynamic_cast<Door*> (*i);
333 door->set_area(door->get_area().x, solids->get_height()*32 - door->get_area().y - 32);
336 for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
338 SpawnPoint* spawn = *i;
339 spawn->pos.y = solids->get_height()*32 - spawn->pos.y - 32;
344 Sector::add_object(GameObject* object)
346 gameobjects_new.push_back(object);
350 Sector::activate(const std::string& spawnpoint)
354 // Apply bonuses from former levels
355 switch (player_status.bonus)
357 case PlayerStatus::NO_BONUS:
360 case PlayerStatus::FLOWER_BONUS:
361 player->got_power = Player::FIRE_POWER; // FIXME: add ice power to here
364 case PlayerStatus::GROWUP_BONUS:
370 for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
372 if((*i)->name == spawnpoint) {
378 std::cerr << "Spawnpoint '" << spawnpoint << "' not found.\n";
380 player->move(sp->pos);
383 camera->reset(Vector(player->base.x, player->base.y));
387 Sector::get_best_spawn_point(Vector pos)
389 Vector best_reset_point = Vector(-1,-1);
391 for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
393 if((*i)->name != "main")
395 if((*i)->pos.x > best_reset_point.x && (*i)->pos.x < pos.x)
396 best_reset_point = (*i)->pos;
399 return best_reset_point;
403 Sector::action(float elapsed_time)
405 player->check_bounds(camera);
407 /* update objects (don't use iterators here, because the list might change
408 * during the iteration)
410 for(size_t i = 0; i < gameobjects.size(); ++i)
411 if(gameobjects[i]->is_valid())
412 gameobjects[i]->action(elapsed_time);
414 /* Handle all possible collisions. */
417 update_game_objects();
421 Sector::update_game_objects()
423 /** cleanup marked objects */
424 for(std::vector<GameObject*>::iterator i = gameobjects.begin();
425 i != gameobjects.end(); /* nothing */) {
426 if((*i)->is_valid() == false) {
427 BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
429 badguys.erase(std::remove(badguys.begin(), badguys.end(), badguy),
432 Bullet* bullet = dynamic_cast<Bullet*> (*i);
435 std::remove(bullets.begin(), bullets.end(), bullet),
438 InteractiveObject* interactive_object =
439 dynamic_cast<InteractiveObject*> (*i);
440 if(interactive_object) {
441 interactive_objects.erase(
442 std::remove(interactive_objects.begin(), interactive_objects.end(),
443 interactive_object), interactive_objects.end());
445 Upgrade* upgrade = dynamic_cast<Upgrade*> (*i);
448 std::remove(upgrades.begin(), upgrades.end(), upgrade),
451 Trampoline* trampoline = dynamic_cast<Trampoline*> (*i);
454 std::remove(trampolines.begin(), trampolines.end(), trampoline),
457 FlyingPlatform* flying_platform= dynamic_cast<FlyingPlatform*> (*i);
458 if(flying_platform) {
459 flying_platforms.erase(
460 std::remove(flying_platforms.begin(), flying_platforms.end(), flying_platform),
461 flying_platforms.end());
463 SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i);
466 std::remove(smoke_clouds.begin(), smoke_clouds.end(), smoke_cloud),
471 i = gameobjects.erase(i);
477 /* add newly created objects */
478 for(std::vector<GameObject*>::iterator i = gameobjects_new.begin();
479 i != gameobjects_new.end(); ++i)
481 BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
483 badguys.push_back(badguy);
484 Bullet* bullet = dynamic_cast<Bullet*> (*i);
486 bullets.push_back(bullet);
487 Upgrade* upgrade = dynamic_cast<Upgrade*> (*i);
489 upgrades.push_back(upgrade);
490 Trampoline* trampoline = dynamic_cast<Trampoline*> (*i);
492 trampolines.push_back(trampoline);
493 FlyingPlatform* flying_platform = dynamic_cast<FlyingPlatform*> (*i);
495 flying_platforms.push_back(flying_platform);
496 InteractiveObject* interactive_object
497 = dynamic_cast<InteractiveObject*> (*i);
498 if(interactive_object)
499 interactive_objects.push_back(interactive_object);
500 SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i);
502 smoke_clouds.push_back(smoke_cloud);
505 gameobjects.push_back(*i);
507 gameobjects_new.clear();
511 Sector::draw(DrawingContext& context)
513 context.push_transform();
514 context.set_translation(camera->get_translation());
516 for(GameObjects::iterator i = gameobjects.begin();
517 i != gameobjects.end(); ++i) {
518 if( (*i)->is_valid() )
522 context.pop_transform();
526 Sector::collision_handler()
528 // CO_BULLET & CO_BADGUY check
529 for(unsigned int i = 0; i < bullets.size(); ++i)
531 for (BadGuys::iterator j = badguys.begin(); j != badguys.end(); ++j)
533 if((*j)->dying != DYING_NOT)
536 if(rectcollision(bullets[i]->base, (*j)->base))
538 // We have detected a collision and now call the
539 // collision functions of the collided objects.
540 (*j)->collision(bullets[i], CO_BULLET, COLLISION_NORMAL);
541 bullets[i]->collision(CO_BADGUY);
542 break; // bullet is invalid now, so break
547 /* CO_BADGUY & CO_BADGUY check */
548 for (BadGuys::iterator i = badguys.begin(); i != badguys.end(); ++i)
550 if((*i)->dying != DYING_NOT)
553 BadGuys::iterator j = i;
555 for (; j != badguys.end(); ++j)
557 if(j == i || (*j)->dying != DYING_NOT)
560 if(rectcollision((*i)->base, (*j)->base))
562 // We have detected a collision and now call the
563 // collision functions of the collided objects.
564 (*j)->collision(*i, CO_BADGUY);
565 (*i)->collision(*j, CO_BADGUY);
569 if(player->dying != DYING_NOT) return;
571 // CO_BADGUY & CO_PLAYER check
572 for (BadGuys::iterator i = badguys.begin(); i != badguys.end(); ++i)
574 if((*i)->dying != DYING_NOT)
577 if(rectcollision_offset((*i)->base, player->base, 0, 0))
579 // We have detected a collision and now call the collision
580 // functions of the collided objects.
581 if (player->previous_base.y < player->base.y &&
582 player->previous_base.y + player->previous_base.height
583 < (*i)->base.y + (*i)->base.height/2
584 && !player->invincible_timer.started())
586 (*i)->collision(player, CO_PLAYER, COLLISION_SQUISH);
590 player->collision(*i, CO_BADGUY);
591 (*i)->collision(player, CO_PLAYER, COLLISION_NORMAL);
596 // CO_UPGRADE & CO_PLAYER check
597 for(unsigned int i = 0; i < upgrades.size(); ++i)
599 if(rectcollision(upgrades[i]->base, player->base))
601 // We have detected a collision and now call the collision
602 // functions of the collided objects.
603 upgrades[i]->collision(player, CO_PLAYER, COLLISION_NORMAL);
607 // CO_TRAMPOLINE & (CO_PLAYER or CO_BADGUY)
608 for (Trampolines::iterator i = trampolines.begin(); i != trampolines.end(); ++i)
610 if (rectcollision((*i)->base, player->base))
612 if (player->previous_base.y < player->base.y &&
613 player->previous_base.y + player->previous_base.height
614 < (*i)->base.y + (*i)->base.height/2)
616 (*i)->collision(player, CO_PLAYER, COLLISION_SQUISH);
618 else if (player->previous_base.y <= player->base.y)
620 player->collision(*i, CO_TRAMPOLINE);
621 (*i)->collision(player, CO_PLAYER, COLLISION_NORMAL);
626 // CO_FLYING_PLATFORM & (CO_PLAYER or CO_BADGUY)
627 for (FlyingPlatforms::iterator i = flying_platforms.begin(); i != flying_platforms.end(); ++i)
629 if (rectcollision((*i)->base, player->base))
631 if (player->previous_base.y < player->base.y &&
632 player->previous_base.y + player->previous_base.height
633 < (*i)->base.y + (*i)->base.height/2)
635 (*i)->collision(player, CO_PLAYER, COLLISION_SQUISH);
636 player->collision(*i, CO_FLYING_PLATFORM);
638 /* else if (player->previous_base.y <= player->base.y)
646 Sector::add_score(const Vector& pos, int s)
648 player_status.score += s;
650 add_object(new FloatingScore(pos, s));
654 Sector::add_bouncy_distro(const Vector& pos)
656 add_object(new BouncyDistro(pos));
660 Sector::add_broken_brick(const Vector& pos, Tile* tile)
662 add_broken_brick_piece(pos, Vector(-1, -4), tile);
663 add_broken_brick_piece(pos + Vector(0, 16), Vector(-1.5, -3), tile);
665 add_broken_brick_piece(pos + Vector(16, 0), Vector(1, -4), tile);
666 add_broken_brick_piece(pos + Vector(16, 16), Vector(1.5, -3), tile);
670 Sector::add_broken_brick_piece(const Vector& pos, const Vector& movement,
673 add_object(new BrokenBrick(tile, pos, movement));
677 Sector::add_bouncy_brick(const Vector& pos)
679 add_object(new BouncyBrick(pos));
683 Sector::add_bad_guy(float x, float y, BadGuyKind kind)
685 BadGuy* badguy = new BadGuy(kind, x, y);
691 Sector::add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind)
693 add_object(new Upgrade(pos, dir, kind));
697 Sector::add_bullet(const Vector& pos, float xm, Direction dir)
699 if(player->got_power == Player::FIRE_POWER)
701 if(bullets.size() > MAX_FIRE_BULLETS-1)
704 else if(player->got_power == Player::ICE_POWER)
706 if(bullets.size() > MAX_ICE_BULLETS-1)
710 Bullet* new_bullet = 0;
711 if(player->got_power == Player::FIRE_POWER)
712 new_bullet = new Bullet(pos, xm, dir, FIRE_BULLET);
713 else if(player->got_power == Player::ICE_POWER)
714 new_bullet = new Bullet(pos, xm, dir, ICE_BULLET);
716 throw std::runtime_error("wrong bullet type.");
717 add_object(new_bullet);
719 SoundManager::get()->play_sound(IDToSound(SND_SHOOT));
725 Sector::add_smoke_cloud(const Vector& pos)
727 add_object(new SmokeCloud(pos));
733 Sector::trybreakbrick(const Vector& pos, bool small)
735 Tile* tile = solids->get_tile_at(pos);
739 sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32));
740 throw SuperTuxException(errmsg, __FILE__, __LINE__);
743 if (tile->attributes & Tile::BRICK)
747 /* Get a distro from it: */
749 Vector(((int)(pos.x + 1) / 32) * 32, (int)(pos.y / 32) * 32));
751 // TODO: don't handle this in a global way but per-tile...
752 if (!counting_distros)
754 counting_distros = true;
762 if (distro_counter <= 0)
764 counting_distros = false;
765 solids->change_at(pos, tile->next_tile);
768 SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
769 player_status.score = player_status.score + SCORE_DISTRO;
770 player_status.distros++;
776 solids->change_at(pos, tile->next_tile);
778 /* Replace it with broken bits: */
779 add_broken_brick(Vector(
780 ((int)(pos.x + 1) / 32) * 32,
781 (int)(pos.y / 32) * 32), tile);
783 /* Get some score: */
784 SoundManager::get()->play_sound(IDToSound(SND_BRICK));
785 player_status.score = player_status.score + SCORE_BRICK;
796 Sector::tryemptybox(const Vector& pos, Direction col_side)
798 Tile* tile = solids->get_tile_at(pos);
802 sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32));
803 throw SuperTuxException(errmsg, __FILE__, __LINE__);
807 if (!(tile->attributes & Tile::FULLBOX))
810 // according to the collision side, set the upgrade direction
816 int posx = ((int)(pos.x+1) / 32) * 32;
817 int posy = (int)(pos.y/32) * 32 - 32;
820 case 1: // Box with a distro!
821 add_bouncy_distro(Vector(posx, posy));
822 SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
823 player_status.score = player_status.score + SCORE_DISTRO;
824 player_status.distros++;
827 case 2: // Add a fire flower upgrade!
828 if (player->size == SMALL) /* Tux is small, add mints! */
829 add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
830 else /* Tux is big, add a fireflower: */
831 add_upgrade(Vector(posx, posy), col_side, UPGRADE_FIREFLOWER);
832 SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
835 case 5: // Add an ice flower upgrade!
836 if (player->size == SMALL) /* Tux is small, add mints! */
837 add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
838 else /* Tux is big, add an iceflower: */
839 add_upgrade(Vector(posx, posy), col_side, UPGRADE_ICEFLOWER);
840 SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
843 case 3: // Add a golden herring
844 add_upgrade(Vector(posx, posy), col_side, UPGRADE_STAR);
847 case 4: // Add a 1up extra
848 add_upgrade(Vector(posx, posy), col_side, UPGRADE_1UP);
855 solids->change_at(pos, tile->next_tile);
858 /* Try to grab a distro: */
860 Sector::trygrabdistro(const Vector& pos, int bounciness)
862 Tile* tile = solids->get_tile_at(pos);
866 sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32));
867 throw SuperTuxException(errmsg, __FILE__, __LINE__); */
869 //Bad tiles (i.e. tiles that are not defined in supertux.stgt but appear in the map) are changed to ID 0 (blank tile)
870 std::cout << "Warning: Undefined tile at " <<(int)pos.x/32 << "/" << (int)pos.y/32 << " (ID: " << (int)solids->get_tile_id_at(pos).id << ")" << std::endl;
871 solids->change_at(pos,0);
872 tile = solids->get_tile_at(pos);
876 if (!(tile->attributes & Tile::COIN))
879 solids->change_at(pos, tile->next_tile);
880 SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
882 if (bounciness == BOUNCE)
884 add_bouncy_distro(Vector(((int)(pos.x + 1) / 32) * 32,
885 (int)(pos.y / 32) * 32));
888 player_status.score = player_status.score + SCORE_DISTRO;
889 player_status.distros++;
893 /* Try to bump a bad guy from below: */
895 Sector::trybumpbadguy(const Vector& pos)
898 for (BadGuys::iterator i = badguys.begin(); i != badguys.end(); ++i)
900 if ((*i)->base.x >= pos.x - 32 && (*i)->base.x <= pos.x + 32 &&
901 (*i)->base.y >= pos.y - 16 && (*i)->base.y <= pos.y + 16)
903 (*i)->collision(player, CO_PLAYER, COLLISION_BUMP);
908 for (unsigned int i = 0; i < upgrades.size(); i++)
910 if (upgrades[i]->base.height == 32 &&
911 upgrades[i]->base.x >= pos.x - 32 && upgrades[i]->base.x <= pos.x + 32 &&
912 upgrades[i]->base.y >= pos.y - 16 && upgrades[i]->base.y <= pos.y + 16)
914 upgrades[i]->collision(player, CO_PLAYER, COLLISION_BUMP);
925 level_song = SoundManager::get()->load_music(datadir + "/music/" + song_title);
927 song_path = (char *) malloc(sizeof(char) * datadir.length() +
928 strlen(song_title.c_str()) + 8 + 5);
929 song_subtitle = strdup(song_title.c_str());
930 strcpy(strstr(song_subtitle, "."), "\0");
931 sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(),
932 song_subtitle, strstr(song_title.c_str(), "."));
933 if(!SoundManager::get()->exists_music(song_path)) {
934 level_song_fast = level_song;
936 level_song_fast = SoundManager::get()->load_music(song_path);
943 Sector::play_music(int type)
946 switch(currentmusic) {
948 SoundManager::get()->play_music(level_song_fast);
951 SoundManager::get()->play_music(level_song);
954 SoundManager::get()->play_music(herring_song);
957 SoundManager::get()->halt_music();
963 Sector::get_music_type()