- more c++-ification
[supertux.git] / src / level.h
1 //
2 // C Interface: level
3 //
4 // Description:
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2003
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #ifndef SUPERTUX_LEVEL_H
14 #define SUPERTUX_LEVEL_H
15
16 #include <string>
17 #include "texture.h"
18 #include "badguy.h"
19 #include "lispreader.h"
20
21 class Tile;
22
23 /** This type holds meta-information about a level-subset. 
24     It could be extended to handle manipulation of subsets. */
25 class st_subset
26   {
27   public:
28     st_subset();
29     static void create(const std::string& subset_name);
30     void load(char *subset);
31     void save();
32     void free();
33
34     std::string name;
35     std::string title;
36     std::string description;
37     texture_type image;
38     int levels;
39  
40   private:
41     void parse(lisp_object_t* cursor);
42   };
43
44 #define LEVEL_NAME_MAX 20
45
46
47 enum TileMapType {
48  TM_BG,
49  TM_IA,
50  TM_FG
51  };
52
53 extern texture_type img_bkgd;
54 extern texture_type img_bkgd_tile[2][4];
55 extern texture_type img_solid[4];
56 extern texture_type img_brick[2];
57
58 class Level 
59 {
60  public:
61   std::string name;
62   std::string theme;
63   std::string song_title;
64   std::string bkgd_image;
65   std::string particle_system;
66   unsigned int* bg_tiles[15]; /* Tiles in the background */
67   unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
68   unsigned int* fg_tiles[15]; /* Tiles in the foreground */
69   int time_left;
70   int bkgd_red;
71   int bkgd_green;
72   int bkgd_blue;
73   int width;
74   float gravity;
75
76   std::vector<BadGuyData> badguy_data;
77  public:
78   /** Will the Level structure with default values */
79   void init_defaults();
80   
81   /** Cleanup the level struct from allocated tile data and such */
82   void cleanup();
83
84   int  load(const char* subset, int level);
85   int  load(const char* filename);
86
87   void load_gfx();
88   void load_song();
89
90   void save(const char* subset, int level);
91
92   /** Edit a piece of the map! */
93   void change(float x, float y, int tm, unsigned int c);
94
95   /** Resize the level to a new width */
96   void change_size (int new_width);
97 };
98
99 void level_load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha);
100 void level_free_song();
101 void level_free_gfx();
102
103 /** Return the id of the tile at the given x/y coordinates */
104 unsigned int gettileid(float x, float y);
105
106 /** Return a pointer to the tile at the given x/y coordinates */
107 Tile* gettile(float x, float y);
108
109 // Some little helper function to check for tile properties
110 bool  issolid(float x, float y);
111 bool  isbrick(float x, float y);
112 bool  isice(float x, float y);
113 bool  isfullbox(float x, float y);
114
115 #endif /*SUPERTUX_LEVEL_H*/