From: Marek Moeckel Date: Tue, 23 Nov 2004 23:20:32 +0000 (+0000) Subject: made secret area trigger work X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=958cad765cf063c9cc3722c3e694c9827ae502a4;p=supertux.git made secret area trigger work TODO: Prevent message from scrolling away with the level (the secret area is in data/levels/test/bonusblock.stl, just hop around on the stones you start on) SVN-Revision: 2163 --- diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index 38e80495c..e26bb65d6 100644 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -11,7 +11,7 @@ (gravity 10.000000) (background (image "arctis.jpg") (speed 0.5)) - (secretarea (x 64) (y 896) (message "You found a secret area!")) + (secretarea (x 128) (y 128) (message "You found a secret area!")) (spawn-points (name "main") (x 100) @@ -52,7 +52,7 @@ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 )) (tilemap @@ -68,7 +68,7 @@ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 - 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 0 0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 2accfbb9e..855d1e34e 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -18,8 +18,7 @@ SecretAreaTrigger::SecretAreaTrigger(const Vector& pos, { bbox.set_pos(pos); bbox.set_size(32, 32); - triggerevent = EVENT_TOUCH; - show_message = 0; + message = "You found a secret area!"; } SecretAreaTrigger::~SecretAreaTrigger() @@ -43,16 +42,20 @@ SecretAreaTrigger::write(LispWriter& writer) void SecretAreaTrigger::draw(DrawingContext& context) { - if (show_message == 1) { - context.draw_center_text(gold_text, message, Vector(0, screen->h/2 - gold_text->get_height()/2), LAYER_GUI); - std::cout<h/2 - gold_text->get_height()/2); + context.draw_center_text(gold_text, message, pos, LAYER_GUI); + //TODO: Prevent text from scrolling with the rest of the level + } + if (message_timer.check()) { + remove_me(); } } void SecretAreaTrigger::event(Player& , EventType type) { - if(type == triggerevent) { - show_message = 1; + if(type == EVENT_TOUCH) { + message_timer.start(MESSAGE_TIME); } } diff --git a/src/trigger/secretarea_trigger.h b/src/trigger/secretarea_trigger.h index d2b6181ca..61ce61ccf 100644 --- a/src/trigger/secretarea_trigger.h +++ b/src/trigger/secretarea_trigger.h @@ -6,6 +6,9 @@ #include "resources.h" #include "video/drawing_context.h" #include "app/globals.h" +#include "timer.h" + +#define MESSAGE_TIME 3 class SecretAreaTrigger : public TriggerBase, public Serializable { @@ -19,9 +22,8 @@ public: void draw(DrawingContext& context); private: - EventType triggerevent; std::string message; - int show_message; + Timer2 message_timer; }; #endif