Made trampolines less likely to interfere with level design:
[supertux.git] / src / worldmap / level.cpp
index 67a1ba9..fbc6b0b 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: worldmap.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//  $Id$
 //
 //  SuperTux
 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
 #include "sprite/sprite_manager.hpp"
 #include "sprite/sprite.hpp"
 #include "video/drawing_context.hpp"
+#include "log.hpp"
+#include "file_system.hpp"
 
 namespace WorldMapNS
 {
 
 LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp)
-  : solved(false), auto_path(true)
+  : solved(false), auto_path(true), basedir(basedir), picture_cached(false), picture(0)
 {
   lisp->get("x", pos.x);
   lisp->get("y", pos.y);
@@ -52,6 +54,7 @@ LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp)
 
 LevelTile::~LevelTile()
 {
+  delete picture;
 }
 
 void
@@ -65,4 +68,17 @@ LevelTile::update(float )
 {
 }
 
+const Surface*
+LevelTile::get_picture()
+{
+  if (picture_cached) return picture;
+  picture_cached = true;
+  std::string fname = FileSystem::strip_extension(basedir + name)+".jpg";
+  if (!PHYSFS_exists(fname.c_str())) {
+       return 0;
+  }
+  picture = new Surface(fname);
+  return picture;
+}
+
 }