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.
19 #ifndef SUPERTUX_TILEMAP_H
20 #define SUPERTUX_TILEMAP_H
25 #include "game_object.h"
26 #include "serializable.h"
27 #include "math/vector.h"
38 * This class is reponsible for drawing the level tiles
40 class TileMap : public GameObject, public Serializable
44 TileMap(const lisp::Lisp& reader, TileManager* tile_manager = 0);
45 TileMap(int layer_, bool solid_, size_t width_, size_t height_);
48 virtual void write(lisp::Writer& writer);
50 virtual void update(float elapsed_time);
51 virtual void draw(DrawingContext& context);
53 void set(int width, int height, const std::vector<unsigned int>& vec,
54 int layer, bool solid);
56 /** resizes the tilemap to a new width and height (tries to not destroy the
59 void resize(int newwidth, int newheight);
61 size_t get_width() const
64 size_t get_height() const
73 /// returns tile in row y and column y (of the tilemap)
74 const Tile* get_tile(int x, int y) const;
75 /// returns tile at position pos (in world coordinates)
76 const Tile* get_tile_at(const Vector& pos) const;
78 void change(int x, int y, uint32_t newtile);
80 void change_at(const Vector& pos, uint32_t newtile);
82 TileManager* get_tilemanager() const
87 void set_drawing_effect(int effect)
89 drawing_effect = effect;
92 int get_drawing_effect()
94 return drawing_effect;
98 typedef std::vector<uint32_t> Tiles;
102 TileManager* tilemanager;
111 #endif /*SUPERTUX_TILEMAP_H*/