X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flevel.h;h=dfb1c1e09b2a62cc8afd677fa7a8727e98cc5a49;hb=aadd77c676baae31db931c8e64cd1713c24289d5;hp=ed93b8b1fd821f137f701ab76116314a1394c76d;hpb=c8ad8bb328dd90c0ab00e4c375b9a4b8f8df6e73;p=supertux.git diff --git a/src/level.h b/src/level.h index ed93b8b1f..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,8 +43,18 @@ 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; @@ -49,7 +62,6 @@ struct 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; @@ -57,29 +69,43 @@ struct st_level int bkgd_blue; int width; float gravity; -}; -enum { - TM_BG, - TM_IA, - TM_DN, - TM_FG - }; + 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, 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*/