X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftilemap.h;h=8aa2b481a21f6a772d10d841ace1e101c680ac75;hb=ee6972038331a3c26a2a6a0bdb2baca25475b1d2;hp=364dabc43daa430335048192ac4d978354527ec9;hpb=403f2652505e814b645892bffaf89a584984f9b8;p=supertux.git diff --git a/src/tilemap.h b/src/tilemap.h index 364dabc43..8aa2b481a 100644 --- a/src/tilemap.h +++ b/src/tilemap.h @@ -1,28 +1,103 @@ -#ifndef __TILEMAP_H__ -#define __TILEMAP_H__ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun +#include + +#include "special/game_object.h" +#include "serializable.h" +#include "math/vector.h" + +using namespace SuperTux; + +namespace SuperTux { +class LispReader; +} class Level; +class TileManager; +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); + TileMap(int layer_, bool solid_, size_t width_, size_t height_); virtual ~TileMap(); + virtual void write(LispWriter& writer); + virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "TileMap"; } + 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); + + /** Flip the all tile map vertically. The purpose of this is to let + player to play the same level in a different way :) */ + void do_vertical_flip(); + + size_t get_width() const + { return width; } + + size_t get_height() const + { return height; } + + int get_layer() const + { return layer; } + + bool is_solid() const + { return solid; } + + /// returns tile in row y and column y (of the tilemap) + const Tile* get_tile(int x, int y) const; + /// returns tile at position pos (in world coordinates) + const Tile* get_tile_at(const Vector& pos) const; + + void change(int x, int y, uint32_t newtile); + + void change_at(const Vector& pos, uint32_t newtile); + +private: + std::vector tiles; private: - Level* level; + TileManager* tilemanager; + bool solid; + float speed; + int width, height; + int layer; + + bool vertical_flip; }; -#endif +#endif /*SUPERTUX_TILEMAP_H*/