New GameObject "Decal" just displays a static, non-interactive image
authorChristoph Sommer <mail@christoph-sommer.de>
Sat, 9 Feb 2008 23:30:43 +0000 (23:30 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Sat, 9 Feb 2008 23:30:43 +0000 (23:30 +0000)
SVN-Revision: 5316

data/images/engine/editor/decal.png [new file with mode: 0644]
data/levels/test/decal.stl [new file with mode: 0644]
src/object/decal.cpp [new file with mode: 0644]
src/object/decal.hpp [new file with mode: 0644]

diff --git a/data/images/engine/editor/decal.png b/data/images/engine/editor/decal.png
new file mode 100644 (file)
index 0000000..87d1423
Binary files /dev/null and b/data/images/engine/editor/decal.png differ
diff --git a/data/levels/test/decal.stl b/data/levels/test/decal.stl
new file mode 100644 (file)
index 0000000..6a7c495
--- /dev/null
@@ -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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 136 137 0 0 0 0 0 0 0 0 0 0 0 0 0 136 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 138 139 0 0 0 0 0 0 0 0 0 0 0 0 0 138 139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 136 137 0 0 0 0 0 0 0 0 0 0 0 0 0 136 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 138 139 0 0 0 0 0 0 0 0 0 0 0 0 0 138 139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+      )
+    )
+    (tilemap
+      (z-pos 0)
+      (solid #t)
+      (width 40)
+      (height 19)
+      (tiles
+      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
+      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 (file)
index 0000000..05ccd1b
--- /dev/null
@@ -0,0 +1,76 @@
+//  $Id$
+//
+//  SuperTux - Decal
+//  Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.expires.deltadevelopment.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 <stdexcept>
+#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 (file)
index 0000000..b29148d
--- /dev/null
@@ -0,0 +1,57 @@
+//  $Id$
+//
+//  SuperTux - Decal
+//  Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.expires.deltadevelopment.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 SUPERTUX_DECAL_H
+#define SUPERTUX_DECAL_H
+
+#include <memory>
+#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<Surface> image; /**< image to draw, anchored at pos */
+};
+
+#endif /*SUPERTUX_DECAL_H*/
+