-// $Id$
-//
// SuperTux - PushButton running a script
// Copyright (C) 2006 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 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 3 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
// 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 <stdexcept>
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "pushbutton.hpp"
-#include "object_factory.hpp"
-#include "player.hpp"
#include "audio/sound_manager.hpp"
-#include "sprite/sprite_manager.hpp"
-#include "sector.hpp"
-#include "log.hpp"
+#include "object/player.hpp"
+#include "object/pushbutton.hpp"
+#include "sprite/sprite.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
+#include "util/reader.hpp"
+
+#include <sstream>
+#include <stdexcept>
namespace {
- const std::string BUTTON_SOUND = "sounds/switch.ogg";
- //14 -> 8
+const std::string BUTTON_SOUND = "sounds/switch.ogg";
+//14 -> 8
}
-PushButton::PushButton(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING), state(OFF)
+PushButton::PushButton(const Reader& lisp) :
+ MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING),
+ script(),
+ state(OFF)
{
- sound_manager->preload(BUTTON_SOUND);
+ SoundManager::current()->preload(BUTTON_SOUND);
set_action("off", -1);
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
{
Player* player = dynamic_cast<Player*>(&other);
if (!player) return FORCE_MOVE;
- float vy = player->physic.get_velocity_y();
+ float vy = player->get_physic().get_velocity_y();
//player->add_velocity(Vector(0, -150));
- player->physic.set_velocity_y(-150);
+ player->get_physic().set_velocity_y(-150);
if (state != OFF) return FORCE_MOVE;
if (!hit.top) return FORCE_MOVE;
set_pos(get_pos() + Vector(0, old_bbox_height - new_bbox_height));
// play sound
- sound_manager->play(BUTTON_SOUND);
+ SoundManager::current()->play(BUTTON_SOUND);
// run script
std::istringstream stream(script);
return FORCE_MOVE;
}
-IMPLEMENT_FACTORY(PushButton, "pushbutton");
+/* EOF */