(yeti
(x 2)
(y 177)
- (dead-script "
-sector.Tux.make_invincible();
-play_sound(\"sounds/yeti_finish.ogg\");
-wait(6);
-Effect.fade_out(5.5);
-wait(5.5);
-Level.finish(true);
-")
+ (dead-script "sector.Tux.trigger_sequence(\"fireworks\");")
)
(particles-snow
)
#include "statistics.hpp"
#include "timer.hpp"
#include "options_menu.hpp"
-#include "object/fireworks.hpp"
#include "textscroller.hpp"
#include "control/codecontroller.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "trigger/sequence_trigger.hpp"
#include "random_generator.hpp"
#include "scripting/squirrel_util.hpp"
+#include "object/endsequence_walkright.hpp"
+#include "object/endsequence_walkleft.hpp"
+#include "object/endsequence_fireworks.hpp"
#include "direction.hpp"
// the engine will be run with a logical framerate of 64fps.
void
GameSession::start_sequence(const std::string& sequencename)
{
- if(sequencename == "endsequence" || sequencename == "fireworks") {
- if(end_sequence)
- return;
+ // handle special "stoptux" sequence
+ if (sequencename == "stoptux") {
+ if (!end_sequence) {
+ log_warning << "Final target reached without an active end sequence" << std::endl;
+ this->start_sequence("endsequence");
+ }
+ if (end_sequence) end_sequence->stop_tux();
+ return;
+ }
+
+ // abort if a sequence is already playing
+ if (end_sequence) return;
+
+ if (sequencename == "endsequence") {
// Determine walking direction for Tux
float xst = 1.f, xend = 2.f;
for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin(); i != currentsector->gameobjects.end(); i++) {
SequenceTrigger* st = dynamic_cast<SequenceTrigger*>(*i);
if(!st)
- continue;
+ continue;
if(st->get_sequence_name() == "stoptux")
- xend = st->get_pos().x;
+ xend = st->get_pos().x;
else if(st->get_sequence_name() == "endsequence")
- xst = st->get_pos().y;
- }
- end_sequence = new EndSequence();
- currentsector->add_object(end_sequence);
- end_sequence->start((xst > xend) ? LEFT : RIGHT);
-
- sound_manager->play_music("music/leveldone.ogg", false);
- currentsector->player->invincible_timer.start(7.3f);
-
- // Stop all clocks.
- for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin();
- i != currentsector->gameobjects.end(); ++i)
- {
- GameObject* obj = *i;
-
- LevelTime* lt = dynamic_cast<LevelTime*> (obj);
- if(lt)
- lt->stop();
+ xst = st->get_pos().y;
}
- if(sequencename == "fireworks") {
- currentsector->add_object(new Fireworks());
- }
- } else if(sequencename == "stoptux") {
- if(!end_sequence) {
- log_warning << "Final target reached without an active end sequence" << std::endl;
- this->start_sequence("endsequence");
+ if (xst > xend) {
+ end_sequence = new EndSequenceWalkLeft();
+ } else {
+ end_sequence = new EndSequenceWalkRight();
}
- if (end_sequence) end_sequence->stop_tux();
- } else {
- log_warning << "Unknown sequence '" << sequencename << "'" << std::endl;
+ }
+ else if (sequencename == "fireworks") end_sequence = new EndSequenceFireworks();
+ else {
+ log_warning << "Unknown sequence '" << sequencename << "'. Ignoring." << std::endl;
+ return;
+ }
+
+ currentsector->add_object(end_sequence);
+ end_sequence->start();
+
+ sound_manager->play_music("music/leveldone.ogg", false);
+ currentsector->player->invincible_timer.start(10000.0f);
+
+ // Stop all clocks.
+ for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin();
+ i != currentsector->gameobjects.end(); ++i)
+ {
+ GameObject* obj = *i;
+
+ LevelTime* lt = dynamic_cast<LevelTime*> (obj);
+ if(lt)
+ lt->stop();
}
}
}
void
-EndSequence::start(Direction dir)
+EndSequence::start()
{
if (isrunning) return;
isrunning = true;
tux.set_controller(end_sequence_controller);
tux.set_speedlimit(230); //MAX_WALK_XM
- walk_dir = dir;
-
starting();
}
void
EndSequence::starting()
{
- last_x_pos = -1;
- endsequence_timer.start(7.3f);
}
void
EndSequence::running(float /*elapsed_time*/)
{
- Player& tux = *Sector::current()->player;
-
- if (tux_may_walk) {
- end_sequence_controller->press((walk_dir == RIGHT) ? Controller::RIGHT : Controller::LEFT);
- if (int(last_x_pos) == int(tux.get_pos().x)) {
- end_sequence_controller->press(Controller::JUMP);
- }
- }
-
- last_x_pos = tux.get_pos().x;
-
- if (endsequence_timer.check()) isdone = true;
}
void
#include "timer.hpp"
#include "lisp/lisp.hpp"
#include "control/codecontroller.hpp"
-#include "direction.hpp"
class EndSequence : public GameObject
{
virtual void update(float elapsed_time);
virtual void draw(DrawingContext& context);
- void start(Direction dir); /**< play EndSequence */
+ void start(); /**< play EndSequence */
void stop_tux(); /**< called when Tux has reached his final position */
void stop(); /**< stop playing EndSequence, mark it as done playing */
bool is_tux_stopped(); /**< returns true if Tux has reached his final position */
virtual void running(float elapsed_time); /**< called while the EndSequence is running */
virtual void stopping(); /**< called when EndSequence stops */
- CodeController* end_sequence_controller;
- float last_x_pos;
- Timer endsequence_timer;
-
-private:
bool isrunning; /**< true while EndSequence plays */
bool isdone; /**< true if EndSequence has finished playing */
bool tux_may_walk; /**< true while tux is allowed to walk */
- Direction walk_dir; /**< direction in which Tux should walk */
+ CodeController* end_sequence_controller;
+
};
#endif
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <config.h>
+#include "endsequence_fireworks.hpp"
+#include "sector.hpp"
+#include "object/player.hpp"
+#include "object/fireworks.hpp"
+
+EndSequenceFireworks::EndSequenceFireworks()
+: EndSequence()
+{
+}
+
+EndSequenceFireworks::~EndSequenceFireworks()
+{
+}
+
+void
+EndSequenceFireworks::draw(DrawingContext& /*context*/)
+{
+}
+
+void
+EndSequenceFireworks::starting()
+{
+ EndSequence::starting();
+ endsequence_timer.start(7.3f);
+ Sector::current()->add_object(new Fireworks());
+}
+
+void
+EndSequenceFireworks::running(float elapsed_time)
+{
+ EndSequence::running(elapsed_time);
+ //Player& tux = *Sector::current()->player;
+
+ if (tux_may_walk) {
+ end_sequence_controller->press(Controller::JUMP);
+ }
+
+ if (endsequence_timer.check()) isdone = true;
+}
+
+void
+EndSequenceFireworks::stopping()
+{
+ EndSequence::stopping();
+}
+
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef __ENDSEQUENCE_FIREWORKS_H__
+#define __ENDSEQUENCE_FIREWORKS_H__
+
+#include <memory>
+#include "object/endsequence.hpp"
+#include "timer.hpp"
+
+class EndSequenceFireworks : public EndSequence
+{
+public:
+ EndSequenceFireworks();
+ virtual ~EndSequenceFireworks();
+ virtual void draw(DrawingContext& context);
+
+protected:
+ virtual void starting(); /**< called when EndSequence starts */
+ virtual void running(float elapsed_time); /**< called while the EndSequence is running */
+ virtual void stopping(); /**< called when EndSequence stops */
+
+ Timer endsequence_timer;
+};
+
+#endif
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <config.h>
+#include "endsequence_walkleft.hpp"
+#include "sector.hpp"
+#include "object/player.hpp"
+
+EndSequenceWalkLeft::EndSequenceWalkLeft()
+: EndSequence()
+{
+}
+
+EndSequenceWalkLeft::~EndSequenceWalkLeft()
+{
+}
+
+void
+EndSequenceWalkLeft::draw(DrawingContext& /*context*/)
+{
+}
+
+void
+EndSequenceWalkLeft::starting()
+{
+ EndSequence::starting();
+ last_x_pos = -1;
+ endsequence_timer.start(7.3f);
+}
+
+void
+EndSequenceWalkLeft::running(float elapsed_time)
+{
+ EndSequence::running(elapsed_time);
+ Player& tux = *Sector::current()->player;
+
+ if (tux_may_walk) {
+ end_sequence_controller->press(Controller::LEFT);
+ if (int(last_x_pos) == int(tux.get_pos().x)) {
+ end_sequence_controller->press(Controller::JUMP);
+ }
+ }
+
+ last_x_pos = tux.get_pos().x;
+
+ if (endsequence_timer.check()) isdone = true;
+}
+
+void
+EndSequenceWalkLeft::stopping()
+{
+ EndSequence::stopping();
+}
+
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef __ENDSEQUENCE_WALKLEFT_H__
+#define __ENDSEQUENCE_WALKLEFT_H__
+
+#include <memory>
+#include "object/endsequence.hpp"
+#include "timer.hpp"
+
+class EndSequenceWalkLeft : public EndSequence
+{
+public:
+ EndSequenceWalkLeft();
+ virtual ~EndSequenceWalkLeft();
+ virtual void draw(DrawingContext& context);
+
+protected:
+ virtual void starting(); /**< called when EndSequence starts */
+ virtual void running(float elapsed_time); /**< called while the EndSequence is running */
+ virtual void stopping(); /**< called when EndSequence stops */
+
+ float last_x_pos;
+ Timer endsequence_timer;
+};
+
+#endif
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <config.h>
+#include "endsequence_walkright.hpp"
+#include "sector.hpp"
+#include "object/player.hpp"
+
+EndSequenceWalkRight::EndSequenceWalkRight()
+: EndSequence()
+{
+}
+
+EndSequenceWalkRight::~EndSequenceWalkRight()
+{
+}
+
+void
+EndSequenceWalkRight::draw(DrawingContext& /*context*/)
+{
+}
+
+void
+EndSequenceWalkRight::starting()
+{
+ EndSequence::starting();
+ last_x_pos = -1;
+ endsequence_timer.start(7.3f);
+}
+
+void
+EndSequenceWalkRight::running(float elapsed_time)
+{
+ EndSequence::running(elapsed_time);
+ Player& tux = *Sector::current()->player;
+
+ if (tux_may_walk) {
+ end_sequence_controller->press(Controller::RIGHT);
+ if (int(last_x_pos) == int(tux.get_pos().x)) {
+ end_sequence_controller->press(Controller::JUMP);
+ }
+ }
+
+ last_x_pos = tux.get_pos().x;
+
+ if (endsequence_timer.check()) isdone = true;
+}
+
+void
+EndSequenceWalkRight::stopping()
+{
+ EndSequence::stopping();
+}
+
--- /dev/null
+// $Id$
+//
+// SuperTux - End Sequence: Tux walks right
+// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef __ENDSEQUENCE_WALKRIGHT_H__
+#define __ENDSEQUENCE_WALKRIGHT_H__
+
+#include <memory>
+#include "object/endsequence.hpp"
+#include "timer.hpp"
+
+class EndSequenceWalkRight : public EndSequence
+{
+public:
+ EndSequenceWalkRight();
+ virtual ~EndSequenceWalkRight();
+ virtual void draw(DrawingContext& context);
+
+protected:
+ virtual void starting(); /**< called when EndSequence starts */
+ virtual void running(float elapsed_time); /**< called while the EndSequence is running */
+ virtual void stopping(); /**< called when EndSequence stops */
+
+ float last_x_pos;
+ Timer endsequence_timer;
+};
+
+#endif