(supertux-sprite
(action
- (name "default")
+ (name "on")
(images
"candle-1.png"
"candle-2.png"
"candle-4.png"
)
)
+ (action
+ (name "off")
+ (images
+ "off.png"
+ )
+ )
)
--- /dev/null
+(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 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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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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")
+ )
+ (spawnpoint
+ (name "main")
+ (x 253.7847)
+ (y 826.1837)
+ )
+ (candle
+ (name "candle1")
+ (burning #f)
+ (x 416)
+ (y 832)
+ )
+ (candle
+ (name "candle2")
+ (burning #f)
+ (x 480)
+ (y 832)
+ )
+ (candle
+ (name "candle3")
+ (x 544)
+ (y 832)
+ )
+ (candle
+ (name "candle4")
+ (burning #f)
+ (x 608)
+ (y 832)
+ )
+ (candle
+ (name "candle5")
+ (burning #f)
+ (x 672)
+ (y 832)
+ )
+ (scripttrigger
+ (script "candle1.set_burning(true);
+wait(0.1);
+candle2.set_burning(true);
+wait(0.1);
+candle3.set_burning(false);
+wait(0.1);
+candle4.set_burning(true);
+wait(0.1);
+candle5.set_burning(true);
+wait(0.1);
+")
+ (button #f)
+ (width 32)
+ (height 32)
+ (x 352)
+ (y 896)
+ )
+ (scripttrigger
+ (script "candle1.set_burning(false);
+wait(0.1);
+candle2.set_burning(false);
+wait(0.1);
+candle3.set_burning(true);
+wait(0.1);
+candle4.set_burning(false);
+wait(0.1);
+candle5.set_burning(false);
+wait(0.1);
+")
+ (button #f)
+ (width 32)
+ (height 32)
+ (x 736)
+ (y 896)
+ )
+ )
+)
#include <config.h>
#include "candle.hpp"
+#include "scripting/candle.hpp"
+#include "scripting/squirrel_util.hpp"
+#include "sector.hpp"
+#include "object/sprite_particle.hpp"
#include "object_factory.hpp"
Candle::Candle(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED)
+ : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED), burning(true), name("")
{
-}
+ lisp.get("name", name);
+ lisp.get("burning", burning);
-void
-Candle::write(lisp::Writer& writer)
-{
- writer.start_list("candle");
- writer.write_float("x", bbox.p1.x);
- writer.write_float("y", bbox.p1.y);
- writer.end_list("candle");
+ if (burning) {
+ sprite->set_action("on");
+ } else {
+ sprite->set_action("off");
+ }
}
HitResponse
return FORCE_MOVE;
}
+void
+Candle::expose(HSQUIRRELVM vm, SQInteger table_idx)
+{
+ if (name == "") return;
+ Scripting::Candle* interface = new Scripting::Candle(this);
+ expose_object(vm, table_idx, interface, name, true);
+}
+
+void
+Candle::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
+{
+ if (name == "") return;
+ Scripting::unexpose_object(vm, table_idx, name);
+}
+
+void
+Candle::puff_smoke()
+{
+ Vector ppos = bbox.get_middle();
+ Vector pspeed = Vector(0, -150);
+ Vector paccel = Vector(0,0);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+}
+
+bool
+Candle::get_burning()
+{
+ return burning;
+}
+
+void
+Candle::set_burning(bool burning)
+{
+ if (this->burning == burning) return;
+ this->burning = burning;
+ if (burning) {
+ sprite->set_action("on");
+ puff_smoke();
+ } else {
+ sprite->set_action("off");
+ puff_smoke();
+ }
+}
+
IMPLEMENT_FACTORY(Candle, "candle");
#ifndef __CANDLE_H__
#define __CANDLE_H__
+#include <string>
+
#include "lisp/lisp.hpp"
#include "object/moving_sprite.hpp"
-#include "serializable.hpp"
+#include "script_interface.hpp"
/**
- * A burning candle: Simple level decoration.
+ * A burning candle: Simple, scriptable level decoration.
*/
-class Candle : public MovingSprite, public Serializable
+class Candle : public MovingSprite, public ScriptInterface
{
public:
Candle(const lisp::Lisp& lisp);
virtual Candle* clone() const { return new Candle(*this); }
- void write(lisp::Writer& writer);
HitResponse collision(GameObject& other, const CollisionHit& hit);
+ virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
+ virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
+
+ void puff_smoke(); /**< spawn a puff of smoke */
+
+ bool get_burning(); /**< returns true if candle is lighted */
+ void set_burning(bool burning); /**< true: light candle, false: extinguish candle */
+
private:
+ bool burning; /**< true if candle is currently lighted */
+ std::string name; /**< user-defined name for use in scripts or empty string if not scriptable */
+
};
#endif
--- /dev/null
+// $Id: candle.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.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 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 <config.h>
+
+#include <string>
+#include <stdio.h>
+#include "object/candle.hpp"
+#include "scripting/candle.hpp"
+#include "math/vector.hpp"
+
+#define NOIMPL log_fatal << __PRETTY_FUNCTION__ << " not implemented."
+
+namespace Scripting
+{
+
+ Candle::Candle(::Candle* candle)
+ : candle(candle)
+ { }
+
+ Candle::~Candle()
+ { }
+
+ bool Candle::get_burning()
+ {
+ return candle->get_burning();
+ }
+
+ void Candle::set_burning(bool burning)
+ {
+ candle->set_burning(burning);
+ }
+
+}
--- /dev/null
+// $Id: candle.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.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 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 __SCRIPTING_CANDLE_H__
+#define __SCRIPTING_CANDLE_H__
+
+#ifndef SCRIPTING_API
+class Candle;
+typedef Candle _Candle;
+#endif
+
+namespace Scripting
+{
+
+class Candle
+{
+public:
+#ifndef SCRIPTING_API
+ Candle(_Candle* candle);
+ ~Candle();
+#endif
+
+ bool get_burning(); /**< returns true if candle is lighted */
+ void set_burning(bool burning); /**< true: light candle, false: extinguish candle */
+
+#ifndef SCRIPTING_API
+ _Candle* candle;
+#endif
+};
+
+}
+
+#endif
+
}
+static SQInteger Candle_release_hook(SQUserPointer ptr, SQInteger )
+{
+ Scripting::Candle* _this = reinterpret_cast<Scripting::Candle*> (ptr);
+ delete _this;
+ return 0;
+}
+
+static SQInteger Candle_get_burning_wrapper(HSQUIRRELVM vm)
+{
+ SQUserPointer data;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) {
+ sq_throwerror(vm, _SC("'get_burning' called without instance"));
+ return SQ_ERROR;
+ }
+ Scripting::Candle* _this = reinterpret_cast<Scripting::Candle*> (data);
+
+ try {
+ bool return_value = _this->get_burning();
+
+ sq_pushbool(vm, return_value);
+ return 1;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'get_burning'"));
+ return SQ_ERROR;
+ }
+
+}
+
+static SQInteger Candle_set_burning_wrapper(HSQUIRRELVM vm)
+{
+ SQUserPointer data;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) {
+ sq_throwerror(vm, _SC("'set_burning' called without instance"));
+ return SQ_ERROR;
+ }
+ Scripting::Candle* _this = reinterpret_cast<Scripting::Candle*> (data);
+ SQBool arg0;
+ if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a bool"));
+ return SQ_ERROR;
+ }
+
+ try {
+ _this->set_burning(arg0 == SQTrue);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'set_burning'"));
+ return SQ_ERROR;
+ }
+
+}
+
static SQInteger display_wrapper(HSQUIRRELVM vm)
{
return Scripting::display(vm);
sq_remove(v, -2); // remove root table
}
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Candle* object, bool setup_releasehook)
+{
+ using namespace Wrapper;
+
+ sq_pushroottable(v);
+ sq_pushstring(v, "Candle", -1);
+ if(SQ_FAILED(sq_get(v, -2))) {
+ std::ostringstream msg;
+ msg << "Couldn't resolved squirrel type 'Candle'";
+ throw SquirrelError(v, msg.str());
+ }
+
+ if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
+ std::ostringstream msg;
+ msg << "Couldn't setup squirrel instance for object of type 'Candle'";
+ throw SquirrelError(v, msg.str());
+ }
+ sq_remove(v, -2); // remove object name
+
+ if(setup_releasehook) {
+ sq_setreleasehook(v, -1, Candle_release_hook);
+ }
+
+ sq_remove(v, -2); // remove root table
+}
+
void register_supertux_wrapper(HSQUIRRELVM v)
{
using namespace Wrapper;
throw SquirrelError(v, "Couldn't register class 'Platform'");
}
+ // Register class Candle
+ sq_pushstring(v, "Candle", -1);
+ if(sq_newclass(v, SQFalse) < 0) {
+ std::ostringstream msg;
+ msg << "Couldn't create new class 'Candle'";
+ throw SquirrelError(v, msg.str());
+ }
+ sq_pushstring(v, "get_burning", -1);
+ sq_newclosure(v, &Candle_get_burning_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'get_burning'");
+ }
+
+ sq_pushstring(v, "set_burning", -1);
+ sq_newclosure(v, &Candle_set_burning_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'set_burning'");
+ }
+
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register class 'Candle'");
+ }
+
}
} // end of namespace Scripting
void create_squirrel_instance(HSQUIRRELVM v, Scripting::Player* object, bool setup_releasehook = false);
void create_squirrel_instance(HSQUIRRELVM v, Scripting::FloatingImage* object, bool setup_releasehook = false);
void create_squirrel_instance(HSQUIRRELVM v, Scripting::Platform* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Candle* object, bool setup_releasehook = false);
}
#include "floating_image.hpp"
#include "anchor_points.hpp"
#include "platform.hpp"
+#include "candle.hpp"