X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flevel.h;h=dfb1c1e09b2a62cc8afd677fa7a8727e98cc5a49;hb=aadd77c676baae31db931c8e64cd1713c24289d5;hp=f9cdbff7e3ad4c3d312f742b38817aaa2bba106b;hpb=7b10050a21caeb94ee3adf5a38a332b26482cf7f;p=supertux.git diff --git a/src/level.h b/src/level.h index f9cdbff7e..dfb1c1e09 100644 --- a/src/level.h +++ b/src/level.h @@ -15,10 +15,13 @@ #include #include "texture.h" +#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: @@ -40,34 +43,69 @@ class st_subset #define LEVEL_NAME_MAX 20 -struct st_level + +enum TileMapType { + TM_BG, + TM_IA, + TM_FG + }; + +class Level { + public: + texture_type img_bkgd; + std::string name; std::string theme; std::string song_title; std::string bkgd_image; - unsigned int* tiles[15]; + 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* fg_tiles[15]; /* Tiles in the foreground */ int time_left; int bkgd_red; int bkgd_green; int bkgd_blue; int width; float gravity; + + std::vector 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); }; -extern texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2]; - -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, unsigned char c); -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*/