- updated es.po
[supertux.git] / src / tilemap.h
1 //  $Id$
2 //
3 //  SuperTux -  A Jump'n Run
4 //  Copyright (C) 2004 Matthias Braun <matze@braunis.de
5 //
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.
10 //
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.
15 //
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 __TILEMAP_H__
20 #define __TILEMAP_H__
21
22 #include <vector>
23 #include "game_object.h"
24 #include "serializable.h"
25 #include "vector.h"
26
27 class Level;
28 class TileManager;
29 class LispReader;
30 class Tile;
31
32 /**
33  * This class is reponsible for drawing the level tiles
34  */
35 class TileMap : public GameObject, public Serializable
36 {
37 public:
38   TileMap();
39   TileMap(LispReader& reader);
40   virtual ~TileMap();
41
42   virtual void write(LispWriter& writer);
43
44   virtual void action(float elapsed_time);
45   virtual void draw(DrawingContext& context);
46
47   void set(int width, int height, const std::vector<unsigned int>& vec,
48       int layer, bool solid);
49
50   /** resizes the tilemap to a new width and height (tries to not destroy the
51    * existing map)
52    */
53   void resize(int newwidth, int newheight);
54
55   size_t get_width() const
56   { return width; }
57
58   size_t get_height() const
59   { return height; }
60   
61   bool is_solid() const
62   { return solid; }
63
64   unsigned int get_tile_id_at(const Vector& pos) const;
65
66   /// returns tile in row y and column y (of the tilemap)
67   Tile* get_tile(int x, int y) const;
68   /// returns tile at position pos (in world coordinates)
69   Tile* get_tile_at(const Vector& pos) const;
70
71   void change(int x, int y, unsigned int newtile);
72
73   void change_at(const Vector& pos, unsigned int newtile);
74
75 public:
76   std::vector<unsigned int> tiles;
77   
78 private:
79   TileManager* tilemanager;
80   bool solid;
81   float speed;
82   int width, height;
83   int layer;
84 };
85
86 #endif
87