X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftilemap.h;h=b629ccd647989df98031b2eaa6770fdfabd8a850;hb=828b5e1ef1cb89d830735f24dd79bbd9b09d5b32;hp=a1cc142a17c7ae39ebac067fa314b63ddd7ca234;hpb=b8c83bae1b0cd0367b6e3ac8c4c28e077eb1b594;p=supertux.git diff --git a/src/tilemap.h b/src/tilemap.h index a1cc142a1..b629ccd64 100644 --- a/src/tilemap.h +++ b/src/tilemap.h @@ -19,25 +19,68 @@ #ifndef __TILEMAP_H__ #define __TILEMAP_H__ +#include #include "game_object.h" -#include "drawable.h" +#include "serializable.h" +#include "vector.h" class Level; +class TileManager; +class LispReader; +class Tile; /** * This class is reponsible for drawing the level tiles */ -class TileMap : public GameObject, public Drawable +class TileMap : public GameObject, public Serializable { public: - TileMap(DisplayManager& manager, Level* level); + TileMap(); + TileMap(LispReader& reader); virtual ~TileMap(); + virtual void write(LispWriter& writer); + virtual void action(float elapsed_time); - virtual void draw(Camera& viewport, int layer); + virtual void draw(DrawingContext& context); + + void set(int width, int height, const std::vector& vec, + int layer, bool solid); + + /** resizes the tilemap to a new width and height (tries to not destroy the + * existing map) + */ + void resize(int newwidth, int newheight); + + size_t get_width() const + { return width; } + + size_t get_height() const + { return height; } + + bool is_solid() const + { return solid; } + + unsigned int get_tile_id_at(const Vector& pos) const; + + /// returns tile in row y and column y (of the tilemap) + Tile* get_tile(int x, int y) const; + /// returns tile at position pos (in world coordinates) + Tile* get_tile_at(const Vector& pos) const; + + void change(int x, int y, unsigned int newtile); + + void change_at(const Vector& pos, unsigned int newtile); + +public: + std::vector tiles; private: - Level* level; + TileManager* tilemanager; + bool solid; + float speed; + int width, height; + int layer; }; #endif