From d54bc022663f96293582cfd13b3bb19b7b91b048 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Sun, 15 Jan 2006 21:08:05 +0000 Subject: [PATCH] * Implemented a way to modify extro parameters as a complement to Wansti's new music * Forgot to check in implementations of stay-on-platform for Mr Bomb and Mr Iceblock; doing so now * Little fix to statistics * Fixes to a few converted bonus2 levels * Anubis's level now has a custom extro SVN-Revision: 2997 --- data/levels/bonus2/level11.stl | 3 +++ data/levels/bonus2/level28.stl | 5 ++--- data/levels/world2/level4.stl | 4 ++++ src/badguy/dispenser.cpp | 8 ++++---- src/badguy/mrbomb.cpp | 19 ++++++++++++++++++- src/badguy/mrbomb.hpp | 4 +++- src/badguy/mriceblock.cpp | 5 ++++- src/badguy/mriceblock.hpp | 2 +- src/game_session.cpp | 6 +++--- src/level.cpp | 13 ++++++++++++- src/level.hpp | 2 ++ src/statistics.cpp | 8 +++++--- 12 files changed, 61 insertions(+), 18 deletions(-) diff --git a/data/levels/bonus2/level11.stl b/data/levels/bonus2/level11.stl index 36142a64b..c2b955613 100644 --- a/data/levels/bonus2/level11.stl +++ b/data/levels/bonus2/level11.stl @@ -83,6 +83,9 @@ (leveltime (time 400) ) + (camera + (mode "normal") + ) (spawnpoint (name "main") (x 100) diff --git a/data/levels/bonus2/level28.stl b/data/levels/bonus2/level28.stl index f4bb13e67..c27088557 100644 --- a/data/levels/bonus2/level28.stl +++ b/data/levels/bonus2/level28.stl @@ -80,9 +80,8 @@ ) ) (background - (color_top 0 0 0) - (color_bottom 255 255 255) - (speed 0.5) + (top_color 0.0 0.0 0.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 200) diff --git a/data/levels/world2/level4.stl b/data/levels/world2/level4.stl index d0aa910a5..d6e4decdf 100644 --- a/data/levels/world2/level4.stl +++ b/data/levels/world2/level4.stl @@ -3,6 +3,10 @@ (version 2) (name (_ "Going Underground")) (author "Anubis") + (extro + (music "gameover_forest.ogg") + (length 12.7) + ) (sector (name "main") (music "forest2.ogg") diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 4aea90c1b..010e9c792 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -95,9 +95,9 @@ Dispenser::launch_badguy() else if (badguy == "bouncingsnowball") Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); else if (badguy == "mrbomb") - Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir)); + Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir, false)); else if (badguy == "mriceblock") - Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); + Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false)); else if (badguy == "snowsnail") Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir)); else if (badguy == "mrrocket") { @@ -110,8 +110,8 @@ Dispenser::launch_badguy() { case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir)); break; case 1: Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); break; - case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir)); break; - case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); break; + case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir, false)); break; + case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false)); break; case 4: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); break; case 5: Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir)); break; } diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 282961687..d38ef8d67 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -28,15 +28,18 @@ MrBomb::MrBomb(const lisp::Lisp& reader) { reader.get("x", start_position.x); reader.get("y", start_position.y); + stay_on_platform = false; + reader.get("stay-on-platform", stay_on_platform); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite"); set_direction = false; } -MrBomb::MrBomb(float pos_x, float pos_y, Direction d) +MrBomb::MrBomb(float pos_x, float pos_y, Direction d, bool stay_on_plat = false) { start_position.x = pos_x; start_position.y = pos_y; + stay_on_platform = stay_on_plat; bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite"); set_direction = true; @@ -50,6 +53,7 @@ MrBomb::write(lisp::Writer& writer) writer.write_float("x", start_position.x); writer.write_float("y", start_position.y); + writer.write_bool("stay-on-platform", stay_on_platform); writer.end_list("mrbomb"); } @@ -62,6 +66,19 @@ MrBomb::activate() sprite->set_action(dir == LEFT ? "left" : "right"); } +void +MrBomb::active_update(float elapsed_time) +{ + if (stay_on_platform && may_fall_off_platform()) + { + dir = (dir == LEFT ? RIGHT : LEFT); + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + BadGuy::active_update(elapsed_time); +} + bool MrBomb::collision_squished(Player& player) { diff --git a/src/badguy/mrbomb.hpp b/src/badguy/mrbomb.hpp index 8fa7f5aa7..8495f0031 100644 --- a/src/badguy/mrbomb.hpp +++ b/src/badguy/mrbomb.hpp @@ -27,9 +27,10 @@ class MrBomb : public BadGuy { public: MrBomb(const lisp::Lisp& reader); - MrBomb(float pos_x, float pos_y, Direction d); + MrBomb(float pos_x, float pos_y, Direction d, bool stay_on_plat); void activate(); + void active_update(float elapsed_time); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); @@ -38,6 +39,7 @@ public: protected: bool collision_squished(Player& player); bool set_direction; + bool stay_on_platform; Direction initial_direction; }; diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 863fd9ed9..782062b76 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -32,17 +32,19 @@ MrIceBlock::MrIceBlock(const lisp::Lisp& reader) { reader.get("x", start_position.x); reader.get("y", start_position.y); + stay_on_platform = false; reader.get("stay-on-platform", stay_on_platform); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("mriceblock"); set_direction = false; } -MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d) +MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d, bool stay_on_plat = false ) : ice_state(ICESTATE_NORMAL), squishcount(0) { start_position.x = pos_x; start_position.y = pos_y; + stay_on_platform = stay_on_plat; bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("mriceblock"); set_direction = true; @@ -56,6 +58,7 @@ MrIceBlock::write(lisp::Writer& writer) writer.write_float("x", start_position.x); writer.write_float("y", start_position.y); + writer.write_bool("stay-on-platform", stay_on_platform); writer.end_list("mriceblock"); } diff --git a/src/badguy/mriceblock.hpp b/src/badguy/mriceblock.hpp index a884aa8de..4f5d9576e 100644 --- a/src/badguy/mriceblock.hpp +++ b/src/badguy/mriceblock.hpp @@ -28,7 +28,7 @@ class MrIceBlock : public BadGuy, public Portable { public: MrIceBlock(const lisp::Lisp& reader); - MrIceBlock(float pos_x, float pos_y, Direction d); + MrIceBlock(float pos_x, float pos_y, Direction d, bool stay_on_plat); void activate(); void write(lisp::Writer& writer); diff --git a/src/game_session.cpp b/src/game_session.cpp index 7ccf19bf7..a63f10844 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -718,10 +718,10 @@ GameSession::start_sequence(const std::string& sequencename) return; end_sequence = ENDSEQUENCE_RUNNING; - endsequence_timer.start(7.0); // 7 seconds until we finish the map + endsequence_timer.start(level->extro_length); // 7 seconds until we finish the map last_x_pos = -1; - sound_manager->play_music("music/leveldone.ogg", false); - currentsector->player->invincible_timer.start(7.0); + sound_manager->play_music("music/" + level->extro_music, false); + currentsector->player->invincible_timer.start(level->extro_length); if(sequencename == "fireworks") { currentsector->add_object(new Fireworks()); diff --git a/src/level.cpp b/src/level.cpp index 8f1885bfb..6c87b816e 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -51,7 +51,7 @@ using namespace std; Level::Level() - : name("noname"), author("Mr. X") + : name("noname"), author("Mr. X"), extro_music("leveldone.ogg"), extro_length(7.0) { } @@ -85,6 +85,17 @@ Level::load(const std::string& filepath) iter.value()->get(name); } else if(token == "author") { iter.value()->get(author); + } else if(token == "extro") { + const lisp::Lisp* ext = iter.lisp(); + lisp::ListIterator ext_iter(ext); + while(ext_iter.next()) { + const std::string& ext_token = ext_iter.item(); + if(ext_token == "music") { + ext_iter.value()->get(extro_music); + } else if(ext_token == "length") { + ext_iter.value()->get(extro_length); + } + } } else if(token == "sector") { Sector* sector = new Sector; sector->parse(*(iter.lisp())); diff --git a/src/level.hpp b/src/level.hpp index 18d180312..2175b3cd9 100644 --- a/src/level.hpp +++ b/src/level.hpp @@ -35,6 +35,8 @@ class Level public: std::string name; std::string author; + std::string extro_music; + float extro_length; typedef std::vector Sectors; Sectors sectors; diff --git a/src/statistics.cpp b/src/statistics.cpp index 6d11616ff..11c03b52d 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -180,7 +180,7 @@ Statistics::draw_message_info(DrawingContext& context, std::string title) //sprintf(str, _( "Max score: %d"), stats[SCORE_STAT][SPLAYER]); //context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 450), CENTER_ALLIGN, LAYER_GUI); - for(int i = 1; i < NUM_STATS; i++) + for(int i = 0; i < NUM_STATS; i++) { if(i == COINS_COLLECTED_STAT) sprintf(str, _("Max coins collected: %d / %d"), @@ -190,14 +190,16 @@ Statistics::draw_message_info(DrawingContext& context, std::string title) sprintf(str, _("Max fragging: %d / %d"), stats[BADGUYS_KILLED_STAT][SPLAYER], stats[BADGUYS_KILLED_STAT][STOTAL]); - else// if(i == TIME_NEEDED_STAT) + else if((i == TIME_NEEDED_STAT) && (stats[TIME_NEEDED_STAT][STOTAL] != -1)) sprintf(str, _("Min time needed: %d / %d"), stats[TIME_NEEDED_STAT][SPLAYER], stats[TIME_NEEDED_STAT][STOTAL]); + else + continue; // y == (462 + i*18) before score removal - context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 450 + i*18), CENTER_ALLIGN, LAYER_GUI); + context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 450 + (i+1)*18), CENTER_ALLIGN, LAYER_GUI); } } -- 2.11.0