From: Christoph Sommer Date: Thu, 1 Jun 2006 22:54:36 +0000 (+0000) Subject: New trigger object "Switch" using public domain images from "mmiikkee12" X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=173b5b4d42c3ad52d1563e6a631390b3390dadbe;p=supertux.git New trigger object "Switch" using public domain images from "mmiikkee12" SVN-Revision: 3619 --- diff --git a/data/images/objects/switch/left-0.png b/data/images/objects/switch/left-0.png new file mode 100644 index 000000000..b05b08902 Binary files /dev/null and b/data/images/objects/switch/left-0.png differ diff --git a/data/images/objects/switch/left-1.png b/data/images/objects/switch/left-1.png new file mode 100644 index 000000000..43e164cba Binary files /dev/null and b/data/images/objects/switch/left-1.png differ diff --git a/data/images/objects/switch/left-2.png b/data/images/objects/switch/left-2.png new file mode 100644 index 000000000..de90ba83c Binary files /dev/null and b/data/images/objects/switch/left-2.png differ diff --git a/data/images/objects/switch/left.sprite b/data/images/objects/switch/left.sprite new file mode 100644 index 000000000..0e0b9b6a9 --- /dev/null +++ b/data/images/objects/switch/left.sprite @@ -0,0 +1,31 @@ +(supertux-sprite + (action + (name "off") + (hitbox 11 2 20 44) + (images + "left-0.png" + ) + ) + (action + (name "turnon") + (hitbox 11 2 20 44) + (images + "left-1.png" + ) + ) + (action + (name "on") + (hitbox 11 2 20 44) + (images + "left-2.png" + ) + ) + (action + (name "turnoff") + (hitbox 11 2 20 44) + (images + "left-1.png" + ) + ) +) + diff --git a/data/images/objects/switch/right-0.png b/data/images/objects/switch/right-0.png new file mode 100644 index 000000000..eed64583c Binary files /dev/null and b/data/images/objects/switch/right-0.png differ diff --git a/data/images/objects/switch/right-1.png b/data/images/objects/switch/right-1.png new file mode 100644 index 000000000..e7afca8ce Binary files /dev/null and b/data/images/objects/switch/right-1.png differ diff --git a/data/images/objects/switch/right-2.png b/data/images/objects/switch/right-2.png new file mode 100644 index 000000000..0bce29235 Binary files /dev/null and b/data/images/objects/switch/right-2.png differ diff --git a/data/images/objects/switch/right.sprite b/data/images/objects/switch/right.sprite new file mode 100644 index 000000000..88bf7aa09 --- /dev/null +++ b/data/images/objects/switch/right.sprite @@ -0,0 +1,31 @@ +(supertux-sprite + (action + (name "off") + (hitbox 0 2 20 43) + (images + "right-0.png" + ) + ) + (action + (name "turnon") + (hitbox 0 2 20 43) + (images + "right-1.png" + ) + ) + (action + (name "on") + (hitbox 0 2 20 43) + (images + "right-2.png" + ) + ) + (action + (name "turnoff") + (hitbox 0 2 20 43) + (images + "right-1.png" + ) + ) +) + diff --git a/data/images/objects/switch/right.xcf b/data/images/objects/switch/right.xcf new file mode 100644 index 000000000..17c7b885c Binary files /dev/null and b/data/images/objects/switch/right.xcf differ diff --git a/data/images/objects/switch/switch-0.png b/data/images/objects/switch/switch-0.png new file mode 100644 index 000000000..eda973ac4 Binary files /dev/null and b/data/images/objects/switch/switch-0.png differ diff --git a/data/images/objects/switch/switch-1.png b/data/images/objects/switch/switch-1.png new file mode 100644 index 000000000..2133f37a1 Binary files /dev/null and b/data/images/objects/switch/switch-1.png differ diff --git a/data/images/objects/switch/switch-2.png b/data/images/objects/switch/switch-2.png new file mode 100644 index 000000000..0e2da7a4b Binary files /dev/null and b/data/images/objects/switch/switch-2.png differ diff --git a/data/images/objects/switch/switch.sprite b/data/images/objects/switch/switch.sprite new file mode 100644 index 000000000..1e9ced1f2 --- /dev/null +++ b/data/images/objects/switch/switch.sprite @@ -0,0 +1,31 @@ +(supertux-sprite + (action + (name "off") + (hitbox 3 4 25 39) + (images + "switch-0.png" + ) + ) + (action + (name "turnon") + (hitbox 3 4 25 39) + (images + "switch-1.png" + ) + ) + (action + (name "on") + (hitbox 3 4 25 39) + (images + "switch-2.png" + ) + ) + (action + (name "turnoff") + (hitbox 3 4 25 39) + (images + "switch-1.png" + ) + ) +) + diff --git a/data/levels/test/switch.stl b/data/levels/test/switch.stl new file mode 100644 index 000000000..4733488d8 --- /dev/null +++ b/data/levels/test/switch.stl @@ -0,0 +1,172 @@ +(supertux-level + (version 2) + (name (_ "Flying Platform Test")) + (author "Marek") + (sector + (name "main") + (background + (x 0) + (y 0) + (image "images/background/arctis.jpg") + (speed 0.5) + ) + (tilemap + (z-pos -100) + (solid #f) + (speed 1) + (width 30) + (height 30) + (tiles 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 61 61 61 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 0 0 0 0 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 1000 1001 1002 1002 1002 1002 1003 0 0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61) + ) + (tilemap + (z-pos 100) + (solid #f) + (speed 1) + (width 30) + (height 30) + (tiles 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) + ) + (camera + (mode "normal") + ) + (jumpy + (x 140) + (y 750) + ) + (spawnpoint + (name "main") + (x 340) + (y 800) + ) + (switch + (script "platform1.goto_node(1);") + (x 576) + (y 864) + (sprite "images/objects/switch/right.sprite") + ) + (switch + (script "platform1.goto_node(1);") + (x 908) + (y 864) + (sprite "images/objects/switch/left.sprite") + ) + (switch + (script "platform1.goto_node(0);") + (x 736) + (y 864) + (sprite "images/objects/switch/switch.sprite") + ) + (platform + (sprite "images/objects/platforms/small.sprite") + (path + (mode "pingpong") + (node + (x 200) + (y 850) + ) + (node + (x 200) + (y 750) + (time 0.5) + ) + (node + (x 100) + (y 750) + ) + ) + ) + (platform + (sprite "images/objects/platforms/small.sprite") + (path + (mode "pingpong") + (node + (x 264) + (y 850) + ) + (node + (x 264) + (y 850) + ) + (node + (x 264) + (y 750) + ) + (node + (x 264) + (y 750) + ) + ) + ) + (platform + (sprite "images/objects/platforms/small.sprite") + (path + (mode "circular") + (node + (x 328) + (y 850) + ) + (node + (x 328) + (y 850) + ) + (node + (x 328) + (y 750) + (time 2) + ) + ) + ) + (platform + (sprite "images/objects/platforms/small.sprite") + (path + (mode "circular") + (node + (x 392) + (y 850) + ) + (node + (x 392) + (y 750) + ) + (node + (x 392) + (y 650) + (time 0.6) + ) + (node + (x 392) + (y 750) + ) + ) + ) + (platform + (name "platform1") + (running #f) + (sprite "images/objects/platforms/vertical-wood.sprite") + (path + (mode "circular") + (node + (x 832) + (y 800) + ) + (node + (x 832) + (y 704) + ) + ) + ) + (powerup + (x 100) + (y 700) + (sprite "images/powerups/egg/egg.sprite") + ) + ) +) diff --git a/src/trigger/switch.cpp b/src/trigger/switch.cpp new file mode 100644 index 000000000..068b0f45b --- /dev/null +++ b/src/trigger/switch.cpp @@ -0,0 +1,113 @@ +// $Id$ +// +// SuperTux - Switch Trigger +// Copyright (C) 2006 Christoph Sommer +// +// 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 "switch.hpp" +#include "object_factory.hpp" +#include "sprite/sprite.hpp" +#include "sprite/sprite_manager.hpp" +#include "sector.hpp" + +Switch::Switch(const lisp::Lisp& reader) + : state(OFF) +{ + if (!reader.get("x", bbox.p1.x)) throw std::runtime_error("no x position set"); + if (!reader.get("y", bbox.p1.y)) throw std::runtime_error("no y position set"); + if (!reader.get("sprite", sprite_name)) throw std::runtime_error("no sprite name set"); + sprite = sprite_manager->create(sprite_name); + bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); + + if (!reader.get("script", script)) throw std::runtime_error("no script set"); +} + +Switch::~Switch() +{ + delete sprite; +} + +void +Switch::write(lisp::Writer& writer) +{ + writer.start_list("switch"); + writer.write_float("x", bbox.p1.x); + writer.write_float("y", bbox.p1.y); + writer.write_string("sprite", sprite_name); + writer.write_string("script", script); + writer.end_list("switch"); +} + +void +Switch::update(float ) +{ + switch (state) { + case OFF: + break; + case TURN_ON: + if(sprite->animation_done()) { + std::istringstream stream(script); + Sector::current()->run_script(stream, "Switch"); + + sprite->set_action("on", 1); + state = ON; + } + break; + case ON: + if(sprite->animation_done()) { + sprite->set_action("turnoff", 1); + state = TURN_OFF; + } + break; + case TURN_OFF: + if(sprite->animation_done()) { + sprite->set_action("off"); + state = OFF; + } + break; + } +} + +void +Switch::draw(DrawingContext& context) +{ + sprite->draw(context, bbox.p1, LAYER_TILES); +} + +void +Switch::event(Player& , EventType type) +{ + if(type != EVENT_ACTIVATE) return; + + switch (state) { + case OFF: + sprite->set_action("turnon", 1); + state = TURN_ON; + break; + case TURN_ON: + break; + case ON: + break; + case TURN_OFF: + break; + } + +} + +IMPLEMENT_FACTORY(Switch, "switch"); + diff --git a/src/trigger/switch.hpp b/src/trigger/switch.hpp new file mode 100644 index 000000000..fecc5b0ff --- /dev/null +++ b/src/trigger/switch.hpp @@ -0,0 +1,60 @@ +// $Id$ +// +// SuperTux - Switch Trigger +// Copyright (C) 2006 Christoph Sommer +// +// 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. + +#ifndef SUPERTUX_DOOR_H +#define SUPERTUX_DOOR_H + +#include + +#include "trigger_base.hpp" +#include "serializable.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include "video/drawing_context.hpp" +#include "sprite/sprite.hpp" + +class Switch : public TriggerBase, public Serializable +{ +public: + Switch(const lisp::Lisp& reader); + virtual ~Switch(); + + virtual void write(lisp::Writer& writer); + + virtual void update(float elapsed_time); + virtual void draw(DrawingContext& context); + virtual void event(Player& player, EventType type); + +private: + enum SwitchState { + OFF, + TURN_ON, + ON, + TURN_OFF + }; + + std::string sprite_name; + Sprite* sprite; + std::string script; + + SwitchState state; + +}; + +#endif