;; Generated by Flexlay Editor
(supertux-level
(version 2)
- (name "No Name")
- (author "No Author")
+ (name "Bonus Block Test")
+ (author "SuperTux Team")
(time 999)
(sector
(name "main")
(gravity 10.000000)
(background (image "arctis.jpg")
(speed 0.5))
+ (secretarea (x 64) (y 896) (message "You found a secret area!"))
(spawn-points
(name "main")
(x 100)
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 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
))
(tilemap
#include "badguy/mriceblock.h"
#include "badguy/mrbomb.h"
#include "trigger/sequence_trigger.h"
+#include "trigger/secretarea_trigger.h"
Sector* Sector::_current = 0;
return partsys;
} else if(name == "door") {
return new Door(reader);
+ } else if(name == "secretarea") {
+ return new SecretAreaTrigger(reader);
} else if(name == "platform") {
return new Platform(reader);
} else if(name == "jumpy" || name == "money") {
--- /dev/null
+#include <config.h>
+
+#include "secretarea_trigger.h"
+#include "utils/lispwriter.h"
+#include "gameloop.h"
+
+SecretAreaTrigger::SecretAreaTrigger(LispReader& reader)
+{
+ reader.read_float("x", bbox.p1.x);
+ reader.read_float("y", bbox.p1.y);
+ bbox.set_size(32, 32);
+
+ reader.read_string("message", message);
+}
+
+SecretAreaTrigger::SecretAreaTrigger(const Vector& pos,
+ const std::string& secretarea)
+{
+ bbox.set_pos(pos);
+ bbox.set_size(32, 32);
+ triggerevent = EVENT_TOUCH;
+ show_message = 0;
+}
+
+SecretAreaTrigger::~SecretAreaTrigger()
+{
+}
+
+void
+SecretAreaTrigger::write(LispWriter& writer)
+{
+ writer.start_list("secretarea");
+
+ writer.write_float("x", bbox.p1.x);
+ writer.write_float("y", bbox.p1.y);
+ writer.write_float("width", bbox.get_width());
+ writer.write_float("height", bbox.get_height());
+ writer.write_string("message", message);
+
+ writer.end_list("secretarea");
+}
+
+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<<message<<std::endl;
+ }
+}
+
+void
+SecretAreaTrigger::event(Player& , EventType type)
+{
+ if(type == triggerevent) {
+ show_message = 1;
+ }
+}
--- /dev/null
+#ifndef __SECRETAREA_TRIGGER_H__
+#define __SECRETAREA_TRIGGER_H__
+
+#include "trigger_base.h"
+#include "serializable.h"
+#include "resources.h"
+#include "video/drawing_context.h"
+#include "app/globals.h"
+
+class SecretAreaTrigger : public TriggerBase, public Serializable
+{
+public:
+ SecretAreaTrigger(LispReader& reader);
+ SecretAreaTrigger(const Vector& pos, const std::string& sequence);
+ ~SecretAreaTrigger();
+
+ void write(LispWriter& writer);
+ void event(Player& player, EventType type);
+ void draw(DrawingContext& context);
+
+private:
+ EventType triggerevent;
+ std::string message;
+ int show_message;
+};
+
+#endif
+