3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2004 Matthias Braun <matze@braunis.de
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.
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.
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 02111-1307, USA.
20 #ifndef SUPERTUX_TILEMAP_H
21 #define SUPERTUX_TILEMAP_H
25 #include "game_object.h"
26 #include "serializable.h"
36 TileId() : id(0), hidden(0) {}
37 explicit TileId(unsigned int i, bool hidden_ = false) : id(i), hidden(hidden_) {}
44 * This class is reponsible for drawing the level tiles
46 class TileMap : public GameObject, public Serializable
50 TileMap(LispReader& reader);
51 TileMap(int layer_, bool solid_, size_t width_, size_t height_);
54 virtual void write(LispWriter& writer);
56 virtual void action(float elapsed_time);
57 virtual void draw(DrawingContext& context);
59 void set(int width, int height, const std::vector<unsigned int>& vec,
60 int layer, bool solid);
62 /** resizes the tilemap to a new width and height (tries to not destroy the
65 void resize(int newwidth, int newheight);
67 size_t get_width() const
70 size_t get_height() const
79 TileId& get_tile_id_at(const Vector& pos);
81 /// returns tile in row y and column y (of the tilemap)
82 Tile* get_tile(int x, int y) const;
83 /// returns tile at position pos (in world coordinates)
84 Tile* get_tile_at(const Vector& pos) const;
86 void change(int x, int y, unsigned int newtile);
88 void change_at(const Vector& pos, unsigned int newtile);
91 std::vector<TileId> tiles;
94 TileManager* tilemanager;
101 #endif /*SUPERTUX_TILEMAP_H*/