From: Ricardo Cruz Date: Thu, 16 Sep 2004 18:56:09 +0000 (+0000) Subject: Added support for setting up end sequence animations on levels. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b83457d64b44e5a3c5071a2f5ecf5c624000f9af;p=supertux.git Added support for setting up end sequence animations on levels. Tag: (end-sequence-animation "fireworks") fireworks is only supported currently. SVN-Revision: 1929 --- diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 0ccf68d20..aa5e1c7b9 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -548,14 +548,15 @@ GameSession::check_end_conditions() else if(!end_sequence && endtile && endtile->data == 0) { end_sequence = ENDSEQUENCE_RUNNING; - random_timer.start(200); // start 1st firework + endsequence_timer.start(7000); // 5 seconds until we finish the map last_x_pos = -1; SoundManager::get()->play_music(level_end_song, 0); - endsequence_timer.start(7000); // 5 seconds until we finish the map tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.) // add left time to stats global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone() / 1000); + + random_timer.start(200); // start 1st firework } else if (!end_sequence && tux->is_dead()) { @@ -593,7 +594,8 @@ GameSession::action(double frame_ratio) } // on end sequence make a few fireworks - if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check()) + if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check() && + currentsector->end_sequence_animation() == FIREWORKS_ENDSEQ_ANIM) { Vector epicenter = currentsector->camera->get_translation(); epicenter.x += screen->w * ((float)rand() / RAND_MAX); diff --git a/src/sector.cpp b/src/sector.cpp index c0c86f3ee..9290da48f 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -46,7 +46,7 @@ Sector* Sector::_current = 0; Sector::Sector() : gravity(10), player(0), solids(0), background(0), camera(0), - currentmusic(LEVEL_MUSIC) + currentmusic(LEVEL_MUSIC), end_sequence_animation_type(NONE_ENDSEQ_ANIM) { song_title = "Mortimers_chipdisko.mod"; player = new Player(); @@ -86,6 +86,10 @@ Sector::parse(LispReader& lispreader) } else if(token == "music") { song_title = lisp_string(data); load_music(); + } else if(token == "end-sequence-animation") { + std::string end_seq_anim = lisp_string(data); + if(end_seq_anim == "fireworks") + end_sequence_animation_type = FIREWORKS_ENDSEQ_ANIM; } else if(token == "camera") { if(camera) { std::cerr << "Warning: More than 1 camera defined in sector.\n"; @@ -184,6 +188,13 @@ Sector::parse_old_format(LispReader& reader) add_object(background); } + std::string end_seq_anim; + reader.read_string("end-sequence-animation", end_seq_anim); + if(end_seq_anim == "fireworks") + end_sequence_animation_type = FIREWORKS_ENDSEQ_ANIM; +// else +// end_sequence_animation = NONE_ENDSEQ_ANIM; + std::string particlesystem; reader.read_string("particle_system", particlesystem); if(particlesystem == "clouds") diff --git a/src/sector.h b/src/sector.h index ffd409eaa..d4291c800 100644 --- a/src/sector.h +++ b/src/sector.h @@ -56,6 +56,11 @@ struct SpawnPoint Vector pos; }; +enum { + NONE_ENDSEQ_ANIM, + FIREWORKS_ENDSEQ_ANIM + }; + /** This class holds a sector (a part of a level) and all the game objects * (badguys, player, background, tilemap, ...) */ @@ -126,6 +131,10 @@ public: player to play the same level in a different way :) */ void do_vertical_flip(); + /** Get end sequence animation */ + int end_sequence_animation() + { return end_sequence_animation_type; } + /** @evil@ */ static Sector* current() { return _current; } @@ -140,6 +149,8 @@ private: MusicRef level_song; MusicRef level_song_fast; + int end_sequence_animation_type; + public: std::string song_title; float gravity;