/* * Copyright (C) 2002,2003 Daniel Heck * * 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. * * $Id: stones.cc,v 1.1 2003/05/10 23:34:29 dheck Exp $ */ #include "stones.hh" #include "objects.hh" #include "object_mixins.hh" using namespace std; using namespace world; using namespace enigma; //---------------------------------------- // EasyModeStone // // // I'm not quite sure what this one is supposed to do, but a stone // like this appears in all Per.Oxyd landscapes that look different in // easy mode. For now, this stone simply does nothing. //---------------------------------------- namespace { class EasyModeStone : public Stone { SINGLETONOBJ(EasyModeStone); public: EasyModeStone() : Stone("st-easymode") {} StoneResponse collision_response(const StoneContact &sc) { return STONE_PASS; } }; } //---------------------------------------- // RotatorStone //---------------------------------------- namespace { class RotatorStone : public Stone, public TimeHandler { public: RotatorStone(bool clockwise) : Stone(clockwise ? "st-rotator-right" : "st-rotator-left"), m_clockwise(clockwise) {} private: static const double RATE = 1.0; bool m_clockwise; Stone *clone() { return new RotatorStone(m_clockwise); } void dispose() { delete this; } void on_creation() { g_timer.set_alarm(this, RATE, true); Stone::on_creation(); } void on_removal() { g_timer.remove_alarm(this); Stone::on_removal(); } void alarm() { GridPos p = get_pos(); if (m_clockwise) { SendImpulse (move(p, NORTH), EAST, this); SendImpulse (move(p, EAST), SOUTH, this); SendImpulse (move(p, SOUTH), WEST, this); SendImpulse (move(p, WEST), NORTH, this); } else { SendImpulse (move(p, NORTH), WEST, this); SendImpulse (move(p, EAST), NORTH, this); SendImpulse (move(p, SOUTH), EAST, this); SendImpulse (move(p, WEST), SOUTH, this); } } void actor_hit (const StoneContact &sc) { } }; } void stones::Init() { Register (new EasyModeStone); Register (new RotatorStone (true)); Register (new RotatorStone (false)); }