- moved some more level_ stuff into the levelclass
[supertux.git] / src / level.h
index 486242e..dfb1c1e 100644 (file)
 #include "badguy.h"
 #include "lispreader.h"
 
-/* This type holds meta-information about a level-subset. */
-/* It could be extended to handle manipulation of subsets. */
+class Tile;
+
+/** This type holds meta-information about a level-subset. 
+    It could be extended to handle manipulation of subsets. */
 class st_subset
   {
   public:
@@ -42,21 +44,17 @@ class st_subset
 #define LEVEL_NAME_MAX 20
 
 
-enum {
+enum TileMapType {
  TM_BG,
  TM_IA,
- TM_DN,
  TM_FG
  };
 
-extern texture_type img_bkgd;
-extern texture_type img_bkgd_tile[2][4];
-extern texture_type img_solid[4];
-extern texture_type img_brick[2];
-
-class st_level 
+class Level 
 {
  public:
+  texture_type img_bkgd;
+
   std::string name;
   std::string theme;
   std::string song_title;
@@ -64,7 +62,6 @@ class st_level
   std::string particle_system;
   unsigned int* bg_tiles[15]; /* Tiles in the background */
   unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
-  unsigned int* dn_tiles[15]; /* Dynamic tiles (bad guys and moving platforms for example)*/
   unsigned int* fg_tiles[15]; /* Tiles in the foreground */
   int time_left;
   int bkgd_red;
@@ -75,20 +72,40 @@ class st_level
 
   std::vector<BadGuyData> badguy_data;
  public:
+  /** Will the Level structure with default values */
+  void init_defaults();
+  
+  /** Cleanup the level struct from allocated tile data and such */
+  void cleanup();
+
+  /** Load data for this level: 
+      Returns -1, if the loading of the level failed. */
+  int  load(const char* subset, int level);
+
+  /** Load data for this level: 
+      Returns -1, if the loading of the level failed. */
+  int  load(const std::string& filename);
+
+  void load_gfx();
+  
+  void load_song();
+  void free_song();
+
+  void save(const char* subset, int level);
+
+  /** Edit a piece of the map! */
+  void change(float x, float y, int tm, unsigned int c);
+
+  /** Resize the level to a new width */
+  void change_size (int new_width);
+
+  /** Return the id of the tile at position x/y */
+  unsigned int gettileid(float x, float y);
+
+  void free_gfx();
+
+  void load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha);
 };
 
-void level_default  (st_level* plevel);
-int  level_load     (st_level* plevel, const char * subset, int level);
-void level_parse    (st_level* plevel, lisp_object_t* cursor);
-int  level_load     (st_level* plevel, const char* filename);
-void level_save     (st_level* plevel, const char * subset, int level);
-void level_free     (st_level* plevel);
-void level_load_gfx (st_level* plevel);
-void level_change   (st_level* plevel, float x, float y, int tm, unsigned int c);
-void level_change_size (st_level* plevel, int new_width);
-void level_load_song(st_level* plevel);
-void level_free_gfx();
-void level_load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha);
-void level_free_song(void);
 
 #endif /*SUPERTUX_LEVEL_H*/