From 173b5b4d42c3ad52d1563e6a631390b3390dadbe Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Thu, 1 Jun 2006 22:54:36 +0000 Subject: [PATCH] New trigger object "Switch" using public domain images from "mmiikkee12" SVN-Revision: 3619 --- data/images/objects/switch/left-0.png | Bin 0 -> 1105 bytes data/images/objects/switch/left-1.png | Bin 0 -> 1099 bytes data/images/objects/switch/left-2.png | Bin 0 -> 1056 bytes data/images/objects/switch/left.sprite | 31 ++++++ data/images/objects/switch/right-0.png | Bin 0 -> 1046 bytes data/images/objects/switch/right-1.png | Bin 0 -> 1080 bytes data/images/objects/switch/right-2.png | Bin 0 -> 1065 bytes data/images/objects/switch/right.sprite | 31 ++++++ data/images/objects/switch/right.xcf | Bin 0 -> 3307 bytes data/images/objects/switch/switch-0.png | Bin 0 -> 763 bytes data/images/objects/switch/switch-1.png | Bin 0 -> 759 bytes data/images/objects/switch/switch-2.png | Bin 0 -> 687 bytes data/images/objects/switch/switch.sprite | 31 ++++++ data/levels/test/switch.stl | 172 +++++++++++++++++++++++++++++++ src/trigger/switch.cpp | 113 ++++++++++++++++++++ src/trigger/switch.hpp | 60 +++++++++++ 16 files changed, 438 insertions(+) create mode 100644 data/images/objects/switch/left-0.png create mode 100644 data/images/objects/switch/left-1.png create mode 100644 data/images/objects/switch/left-2.png create mode 100644 data/images/objects/switch/left.sprite create mode 100644 data/images/objects/switch/right-0.png create mode 100644 data/images/objects/switch/right-1.png create mode 100644 data/images/objects/switch/right-2.png create mode 100644 data/images/objects/switch/right.sprite create mode 100644 data/images/objects/switch/right.xcf create mode 100644 data/images/objects/switch/switch-0.png create mode 100644 data/images/objects/switch/switch-1.png create mode 100644 data/images/objects/switch/switch-2.png create mode 100644 data/images/objects/switch/switch.sprite create mode 100644 data/levels/test/switch.stl create mode 100644 src/trigger/switch.cpp create mode 100644 src/trigger/switch.hpp diff --git a/data/images/objects/switch/left-0.png b/data/images/objects/switch/left-0.png new file mode 100644 index 0000000000000000000000000000000000000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QA89)1jfXx0Kktk zGvU6zzGmP_6?YBP)xz=h-C&Xc`03)s@bTW>E5?`?6H%a63?D~Pv_O*a>fysZBprVN Xi!R-oVd%4100000NkvXXu0mjfBJKe+ literal 0 HcmV?d00001 diff --git a/data/images/objects/switch/left-1.png b/data/images/objects/switch/left-1.png new file mode 100644 index 0000000000000000000000000000000000000000..43e164cba2ecca6e050b8e3191ad1066cbc14d03 GIT binary patch literal 1099 zcmV-R1ho5!P)C*B{m17^)~WFU8GbZ8({Xk{QrNlj4iWF>9@00XZ{L_t(o!{wOGZZganYHvg)Rz-cNX4cGK(XGHL-R4SFQ3Rr6oqY6OWY=&<^nq_Z#RlF+AIHuWb zh6DKc;zg^f$5AEAGSW09P1A4yk+n}7S+iV{B*bw{=3F>{Buyv0_W)#BMwVr$YM3B8 z`S!belO#Ewi=qyIa}M=Bm;#3d4r!}+nx;7C)^Z`t_LE^_EwWDjPA~-lh-43{AcFHA z-}(drn7VL53PrQvRY7$_aYCGi))*=F(D2UTMQ|&oqmr`tr6N z{+E3R?pB6J7l9EG=>ZM^6;-_fd?zAfKyTlGzLL*J`>nOqYBl0GCQVbS)#{cN*sU-D zyjpD3wYXX@mR9fi<$>+KFx0HYg<=lq1)QoL6_F)X?N!x8L~^R?wAKIhPrqdo3j7K< zMKTp*1Xbf5`M43~<3?FTdVxe$jjYA(<3J=LB_IcyS5>qH@X#I@fjjeXx!zY^NQylp z&f2GPNqq0l&OM8@{((cNE&>VgyQ+?eNLfUNfEA!$Rg0>M%7Yz$7!!VJy}Nq-`ImMK z-TE;<@x%4`lOv6!;x?*q=a z52W=FQ9yt%+CBg}-@z2fvh0sEP06whWBx5`Ljins;}N$MenwMC9}KXdYP`Rsn#k z*RHwe4jx?JyxHj(biFY-IcK^F5XbS0{{Z}1{L;}5 RnUMeh002ovPDHLkV1l#b^(+7Y literal 0 HcmV?d00001 diff --git a/data/images/objects/switch/left-2.png b/data/images/objects/switch/left-2.png new file mode 100644 index 0000000000000000000000000000000000000000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`Tyu|=YDZ(&BDTUE`0#Jfu zj3HHu@p#N_zrPs3!YJ5%`Y>n2*6dR zgA=6e_OEfHkjQN?JZN*(=~M$SYBuS9`pjPcJ5Cf3yBl~1AGm97Rs#Sq+HW!1Z_V6n zKi^0at^fcw-_@6nUpxu7-q*3~HB_px>>5tPA_yx4SX-;Hu~mO|2nqv)VF*IxRm6V) zi1M2dGh5nL1rUZ9@w>D(1v9#M2<{cgWiSXfUAIaFqFjCR@FT7iV3LGW31AHDY*z>n zM-!)Fs-&*^7>a!3LKHs=g#lEWzK+YNumYziC#!m31@N)}Wj1G)H94%mJxu4lj*9>+ zf|v`SjX^0z9LGp0O99YYqw{Xb;tokpD$^9-_Zg4J6M$#-iG&ajjS9UCAj>k6B*F7M tyy1`_2+%Vfjb~6$69QG%dMkT1_6v~2a1DKJiYovB002ovPDHLkV1kjrKWzX2 literal 0 HcmV?d00001 diff --git a/data/images/objects/switch/switch-1.png b/data/images/objects/switch/switch-1.png new file mode 100644 index 0000000000000000000000000000000000000000..2133f37a1f5761f41f7fa3fee7f926f84347dbb3 GIT binary patch literal 759 zcmVC*DiBgJYy|)S03CEi zSad^gZEa<4bO1wgWnpw>WFU8GbZ8({Xk{QrNlj4iWF>9@00LV{L_t(o!|j;CPTN2b zhCf?2ln{X$g-}z$slC!3pwCo^heCaxyg@kuX;Yjia^%=?*1J1BI7A^NQ~@VQB_sLZ zwY~H0{^OmUg^j&+bEa>8TwaRrd1P6Ju@*#1cW8{^`^Ck?uQ&ZLSBfp)$M=0C&#~5) z>fBmOHX1!>djJqc5hJB|x4n%v25T)+(kzGwqb%bt3>O1vtx3}qtumBxiVO5$;T3j2#(|6x-P!&i5~dxncM24uItFkp9WZdH{9?1A?n7f@YJ-IJ>2d2JQ26 z{saNTYIU^|)Z1->W|O^E3r{ILrPyn=2%1gmGudt>0QC$R$F}#c7uTHFJC#fmTIR1z@T2|`t+1;5Ud_xSgrE&^C!By752Ja1n9r7 z(G3EIm7Vph10fFK(Gd~^h!uol?@(RWLX;#iMd=`j6g7kZ)kC*2QfZ!CbR$m03CEi zSad^gZEa<4bO1wgWnpw>WFU8GbZ8({Xk{QrNlj4iWF>9@00I+9L_t(o!|j-{Zrd;r zhJV_UW3}Ca1WsIg%8;>MIs|>70(q#QZ&P$}Mh`)T7`77`DFg@-DT=)7V97|*$hB)( z1`^%IBgFf7ccgd+)bid%JRSVFx?rTXsyNf%gd!*=jmjsHCnC<*LA^Z z3L+}iI1xc5$ur$EfFKBvXpQ#40gSaEB5+AwU}hvr;lcNd0gN$-;~2&mFwp{_1jArP zY7D|K#B??*2H-44T5DKqVT>sy3`7L2HG&{O6h*}V8S-NH89RmVjTuL2M=j4@D3L2F%Fc}`ikq_{(p zk?J%>5CjOrZ~?GoiJt!{mk>n&)>}PhLco-@UM+7%{s7QO VSReJii$VYZ002ovPDHLkV1hHX8m9mN literal 0 HcmV?d00001 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 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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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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) + ) + (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 -- 2.11.0