From 3ae73fa8f1f343be8e17cdbf31cb13d0eebcee41 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Sat, 9 Feb 2008 23:30:43 +0000 Subject: [PATCH] New GameObject "Decal" just displays a static, non-interactive image SVN-Revision: 5316 --- data/images/engine/editor/decal.png | Bin 0 -> 897 bytes data/levels/test/decal.stl | 147 ++++++++++++++++++++++++++++++++++++ src/object/decal.cpp | 76 +++++++++++++++++++ src/object/decal.hpp | 57 ++++++++++++++ 4 files changed, 280 insertions(+) create mode 100644 data/images/engine/editor/decal.png create mode 100644 data/levels/test/decal.stl create mode 100644 src/object/decal.cpp create mode 100644 src/object/decal.hpp diff --git a/data/images/engine/editor/decal.png b/data/images/engine/editor/decal.png new file mode 100644 index 0000000000000000000000000000000000000000..87d1423afbcdba694f70999762ab024574c58659 GIT binary patch literal 897 zcmV-{1AhF8P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iO7$ z6)+=Gy$%up0013yMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HRA^-&M@dak?_?!z0008m zNkl4m{P+K@n(>!k%kEYGz{KKdqzwq$B&-?y<&-eE} z@ALgW54+gK{~fVy#O^~Aj-wfMcnS-cz#w{X9laQT6a|#yOu@S zf(D1_>Err$^bRmS0e-`Ie1Uu0otYwhh^V|w^v)U4?64^MS+p=Bn(h^iUlINIRcPZ^ z!n1{u5HmX*a>~m@h?d7H+Ug7(LtjxL=g)EBeU=vab&R`1OwSNo&WgoCOT;P2TkglH zI>HnCN#t|k6E1$r+&pMR|HBG6g|1_D^j#*q#N;RwKdc6vc#n$GaG#f;vXrBTc=dS> zB#FmYWA{EyvW9qq#+T?H1g+@KRX{xkPPNeWC3Dk^ezSgh>d)r>XT^JX_chv1u76ka z0!5{?zCrgj(14q33y9-xeXZm`hM7rj-^fi=f0nmi=IvKPe`cQUUOvA}HsYf*wA8Q9 zt4{HFl7=)lzc-00WLG9E9gj&~y~O=AL5dxaxBM=XjZB_A9b{OY zdbkq49SY6|v-9+i&@;q|qqH{V&Z$mOSVAgIHZqCKj*O`BT(~a&vAX!G%6YaXm{7x^ zof*-Vt@z{4p#K#sE-R*HKdEQ_Zo@mV;w^1PQFaqGY;!aEPj1Km=z-*4Ka%ZY7rXcq X(M36XvVY1u00000NkvXXu0mjfZMvap literal 0 HcmV?d00001 diff --git a/data/levels/test/decal.stl b/data/levels/test/decal.stl new file mode 100644 index 000000000..6a7c4955f --- /dev/null +++ b/data/levels/test/decal.stl @@ -0,0 +1,147 @@ +(supertux-level + (version 2) + (name (_ "Flying Platform Test")) + (author "Marek Moeckel") + (sector + (name "main") + (ambient-light 1 1 1) + (background + (speed 0.5) + (image "images/background/BlueRock_Forest/blue-top.jpg") + ) + (camera + (mode "normal") + ) + (decal + (x 528) + (y 176) + (image "images/creatures/tux/small/walk-0.png") + ) + (decal + (y 176) + (image "images/creatures/tux/small/walk-2.png") + ) + (decal + (x 128) + (y 352) + (image "images/creatures/tux/small/jump-0.png") + ) + (decal + (x 688) + (y 336) + (image "images/creatures/tux/small/skid-0.png") + ) + (decal + (x 736) + (y 432) + (image "images/creatures/nolok/walk-0.png") + ) + (decal + (x 412) + (y 112) + (image "images/creatures/nolok/walk-1.png") + ) + (decal + (x 304) + (y 432) + (image "images/creatures/nolok/walk-1.png") + ) + (decal + (x 752) + (y 400) + (layer -50) + (image "images/objects/particles/smoke-2.png") + ) + (decal + (x 752) + (y 400) + (image "images/objects/particles/smoke-2.png") + ) + (decal + (x 800) + (y 112) + (image "images/creatures/nolok/walk-2.png") + ) + (tilemap + (z-pos -100) + (solid #f) + (width 40) + (height 19) + (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 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 14 14 14 14 14 14 14 14 0 0 0 0 0 0 0 0 0 0 0 + 11 11 11 11 11 11 11 11 11 11 11 11 11 11 131 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 + 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 0 0 131 131 0 0 0 0 131 131 131 + 1311 0 0 0 0 0 0 0 0 0 0 0 0 0 131 1311 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 1311 0 0 0 0 0 0 0 0 0 0 0 0 0 131 1311 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 83 0 0 0 0 0 0 131 0 0 0 0 0 0 0 83 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 8 8 8 8 8 8 8 8 8 8 8 8 8 8 131 8 8 8 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 + 14 14 14 14 14 14 14 14 14 14 14 14 14 14 131 14 14 14 14 14 14 14 14 14 14 14 14 14 14 0 0 0 0 0 0 0 0 0 0 0 + 11 11 11 11 11 11 11 11 11 11 11 11 11 11 131 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 + ) + ) + (tilemap + (z-pos 100) + (solid #f) + (width 40) + (height 19) + (tiles + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131 0 0 0 0 0 0 0 0 0 0 0 0 0 131 131 131 131 131 131 131 131 131 131 131 131 + ) + ) + ) +) diff --git a/src/object/decal.cpp b/src/object/decal.cpp new file mode 100644 index 000000000..05ccd1b9e --- /dev/null +++ b/src/object/decal.cpp @@ -0,0 +1,76 @@ +// $Id$ +// +// SuperTux - Decal +// Copyright (C) 2008 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 +#include "decal.hpp" +#include "camera.hpp" +#include "video/drawing_context.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include "object_factory.hpp" +#include "resources.hpp" +#include "main.hpp" +#include "log.hpp" + +Decal::Decal(const lisp::Lisp& reader) + : layer(LAYER_OBJECTS) +{ + float px = 0; + float py = 0; + reader.get("x", px); + reader.get("y", py); + pos = Vector(px, py); + + if(!reader.get("image", imagefile)) throw std::runtime_error("Must specify image for decal"); + image.reset(new Surface(imagefile)); + + reader.get("layer", layer); +} + +Decal::~Decal() +{ +} + +void +Decal::write(lisp::Writer& writer) +{ + writer.start_list("decal"); + writer.write_float("x", pos.x); + writer.write_float("y", pos.y); + writer.write_string("image", imagefile); + writer.write_int("layer", layer); + writer.end_list("decal"); +} + +void +Decal::update(float) +{ +} + +void +Decal::draw(DrawingContext& context) +{ + if(!image.get()) return; + context.draw_surface(image.get(), pos, layer); +} + +IMPLEMENT_FACTORY(Decal, "decal"); + diff --git a/src/object/decal.hpp b/src/object/decal.hpp new file mode 100644 index 000000000..b29148de2 --- /dev/null +++ b/src/object/decal.hpp @@ -0,0 +1,57 @@ +// $Id$ +// +// SuperTux - Decal +// Copyright (C) 2008 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_DECAL_H +#define SUPERTUX_DECAL_H + +#include +#include "video/surface.hpp" +#include "video/drawing_context.hpp" +#include "game_object.hpp" +#include "serializable.hpp" + +class DisplayManager; + +namespace lisp { +class Lisp; +} + +/** + * Non-interactive, decorative image + */ +class Decal : public GameObject, public Serializable +{ +public: + Decal(const lisp::Lisp& reader); + virtual ~Decal(); + + virtual void write(lisp::Writer& writer); + virtual void update(float elapsed_time); + virtual void draw(DrawingContext& context); + +private: + Vector pos; /**< coordinates of upper-left corner */ + std::string imagefile; /**< name of image to draw */ + int layer; /**< layer to draw on */ + + std::auto_ptr image; /**< image to draw, anchored at pos */ +}; + +#endif /*SUPERTUX_DECAL_H*/ + -- 2.11.0