From: Marek Moeckel Date: Tue, 23 Nov 2004 22:11:09 +0000 (+0000) Subject: added trigger to display (and later count) secret areas X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3df54471553ec420c83fc1c22d4c939f522395fe;p=supertux.git added trigger to display (and later count) secret areas SVN-Revision: 2158 --- diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index e23686a80..38e80495c 100644 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -1,8 +1,8 @@ ;; 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") @@ -11,6 +11,7 @@ (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) @@ -51,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 0 0 0 0 0 0 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 diff --git a/src/sector.cpp b/src/sector.cpp index e4ec1dd79..63a33531e 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -55,6 +55,7 @@ #include "badguy/mriceblock.h" #include "badguy/mrbomb.h" #include "trigger/sequence_trigger.h" +#include "trigger/secretarea_trigger.h" Sector* Sector::_current = 0; @@ -135,6 +136,8 @@ Sector::parseObject(const std::string& name, LispReader& reader) 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") { diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp new file mode 100644 index 000000000..2accfbb9e --- /dev/null +++ b/src/trigger/secretarea_trigger.cpp @@ -0,0 +1,58 @@ +#include + +#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<