X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftrigger%2Fsecretarea_trigger.cpp;h=66a7f2e595323342ab35a3ae302dd84117d01a17;hb=0b585f0dc8e185bcf1a7e281108281f5b2b96706;hp=53bbf8d0e5cd952950418b58aedd18e9b65d3909;hpb=ef57479f613b900b73eba8e8f4d026aae0de25cc;p=supertux.git diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 53bbf8d0e..66a7f2e59 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -1,9 +1,30 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 #include "secretarea_trigger.h" -#include "gameloop.h" +#include "game_session.h" #include "lisp/lisp.h" #include "lisp/writer.h" +#include "object_factory.h" #define MESSAGE_TIME 3.5 @@ -12,16 +33,18 @@ SecretAreaTrigger::SecretAreaTrigger(const lisp::Lisp& reader) { reader.get("x", bbox.p1.x); reader.get("y", bbox.p1.y); - bbox.set_size(32, 32); + float w = 32, h = 32; + reader.get("width", w); + reader.get("height", h); + bbox.set_size(w, h); reader.get("message", message); message_displayed = false; } -SecretAreaTrigger::SecretAreaTrigger(const Vector& pos) +SecretAreaTrigger::SecretAreaTrigger(const Rectangle& area) { - bbox.set_pos(pos); - bbox.set_size(32, 32); + bbox = area; message = "You found a secret area!"; message_displayed = false; } @@ -50,7 +73,7 @@ SecretAreaTrigger::draw(DrawingContext& context) if (message_timer.started()) { context.push_transform(); context.set_translation(Vector(0, 0)); - Vector pos = Vector(0, screen->h/2 - gold_text->get_height()/2); + Vector pos = Vector(0, SCREEN_HEIGHT/2 - gold_text->get_height()/2); context.draw_center_text(gold_text, message, pos, LAYER_GUI); context.pop_transform(); } @@ -69,3 +92,5 @@ SecretAreaTrigger::event(Player& , EventType type) } } } + +IMPLEMENT_FACTORY(SecretAreaTrigger, "secretarea");