class Level;
class TileManager;
class Tile;
+class TileSet;
/**
- * This class is reponsible for drawing the level tiles
+ * This class is responsible for drawing the level tiles
*/
class TileMap : public GameObject, public Serializable, public ScriptInterface
{
public:
- TileMap();
- TileMap(const lisp::Lisp& reader, TileManager* tile_manager = 0);
- TileMap(std::string name, int z_pos, bool solid_, size_t width_, size_t height_);
+ TileMap(const TileSet *tileset);
+ TileMap(const lisp::Lisp& reader);
+ TileMap(const TileSet *tileset, std::string name, int z_pos, bool solid_,
+ size_t width_, size_t height_);
virtual ~TileMap();
virtual void write(lisp::Writer& writer);
/** Stop tilemap at next node */
void stop_moving();
-
+
virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
float get_y_offset() const
{ return y_offset; }
+ const Vector& get_movement() const
+ {
+ return movement;
+ }
+
void set_x_offset(float x_offset)
{ this->x_offset = x_offset; }
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;
+ /// returns tile in row y and column y (of the tilemap)
+ uint32_t get_tile_id(int x, int y) const;
+ /// returns tile at position pos (in world coordinates)
+ uint32_t get_tile_id_at(const Vector& pos) const;
void change(int x, int y, uint32_t newtile);
/// changes all tiles with the given ID
void change_all(uint32_t oldtile, uint32_t newtile);
- TileManager* get_tilemanager() const
- {
- return tilemanager;
- }
-
void set_drawing_effect(DrawingEffect effect)
{
drawing_effect = effect;
/**
* Start fading the tilemap to opacity given by @c alpha.
- * Destination opacity will be reached after @c seconds seconds.
+ * Destination opacity will be reached after @c seconds seconds. Also influences solidity.
*/
void fade(float alpha, float seconds = 0);
+ /**
+ * Instantly switch tilemap's opacity to @c alpha. Also influences solidity.
+ */
+ void set_alpha(float alpha);
+
+ /**
+ * Return tilemap's opacity. Note that while the tilemap is fading in or out, this will return the current alpha value, not the target alpha.
+ */
+ float get_alpha();
+
private:
+ const TileSet *tileset;
+
typedef std::vector<uint32_t> Tiles;
Tiles tiles;
-private:
- TileManager* tilemanager;
bool solid;
float speed_x;
float speed_y;
int z_pos;
float x_offset;
float y_offset;
+ Vector movement; /**< The movement that happened last frame */
DrawingEffect drawing_effect;
float alpha; /**< requested tilemap opacity */
float current_alpha; /**< current tilemap opacity */
float remaining_fade_time; /**< seconds until requested tilemap opacity is reached */
-
+
std::auto_ptr<Path> path;
std::auto_ptr<PathWalker> walker;