Just removed two printfs I have mistakelly committed.
[supertux.git] / src / level.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef SUPERTUX_LEVEL_H
22 #define SUPERTUX_LEVEL_H
23
24 #include <string>
25 #include "texture.h"
26 #include "badguy.h"
27 #include "lispreader.h"
28
29 class Tile;
30
31 /** This type holds meta-information about a level-subset. 
32     It could be extended to handle manipulation of subsets. */
33 class st_subset
34   {
35   public:
36     st_subset();
37     static void create(const std::string& subset_name);
38     void load(char *subset);
39     void save();
40     void free();
41
42     std::string name;
43     std::string title;
44     std::string description;
45     Surface* image;
46     int levels;
47  
48   private:
49     void parse(lisp_object_t* cursor);
50   };
51
52 #define LEVEL_NAME_MAX 20
53
54
55 enum TileMapType {
56  TM_BG,
57  TM_IA,
58  TM_FG
59  };
60
61 struct ResetPoint
62 {
63   int x;
64   int y;
65 };
66
67 class Level 
68 {
69  public:
70   Surface* img_bkgd;
71
72   std::string name;
73   std::string author;
74   std::string theme;
75   std::string song_title;
76   std::string bkgd_image;
77   std::string particle_system;
78   std::vector<unsigned int> bg_tiles[15]; /* Tiles in the background */
79   std::vector<unsigned int> ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
80   std::vector<unsigned int> fg_tiles[15]; /* Tiles in the foreground */
81   int time_left;
82   Color bkgd_top;
83   Color bkgd_bottom;
84   int width;
85   int start_pos_x;
86   int start_pos_y;
87   int  endpos;
88   float gravity;
89
90   std::vector<BadGuyData> badguy_data;
91
92   /** A collection of points to which Tux can be reset after a lost live */
93   std::vector<ResetPoint> reset_points;
94  public:
95   Level();
96   Level(const std::string& subset, int level);
97   Level(const std::string& filename);
98
99   /** Will the Level structure with default values */
100   void init_defaults();
101   
102   /** Cleanup the level struct from allocated tile data and such */
103   void cleanup();
104
105   /** Load data for this level: 
106       Returns -1, if the loading of the level failed. */
107   int  load(const std::string& subset, int level);
108
109   /** Load data for this level: 
110       Returns -1, if the loading of the level failed. */
111   int  load(const std::string& filename);
112
113   void load_gfx();
114   void free_gfx();
115   
116   void load_song();
117   void free_song();
118
119   void save(const char* subset, int level);
120
121   /** Edit a piece of the map! */
122   void change(float x, float y, int tm, unsigned int c);
123
124   /** Resize the level to a new width */
125   void change_size (int new_width);
126
127   /** Return the id of the tile at position x/y */
128   unsigned int gettileid(float x, float y);
129
130   void load_image(Surface** ptexture, std::string theme, const char * file, int use_alpha);
131 };
132
133 #endif /*SUPERTUX_LEVEL_H*/