17 #ifndef HEADER_SUPERTUX_OBJECT_TILEMAP_HPP 18 #define HEADER_SUPERTUX_OBJECT_TILEMAP_HPP 22 #include "math/rect.hpp" 23 #include "math/rectf.hpp" 24 #include "math/size.hpp" 25 #include "object/path_object.hpp" 26 #include "object/path_walker.hpp" 27 #include "squirrel/exposed_object.hpp" 28 #include "scripting/tilemap.hpp" 29 #include "supertux/game_object.hpp" 30 #include "video/color.hpp" 31 #include "video/flip.hpp" 32 #include "video/drawing_target.hpp" 51 virtual std::string get_class()
const override {
return "tilemap"; }
52 virtual const std::string get_icon_path()
const override {
return "images/engine/editor/tilemap.png"; }
53 virtual std::string get_display_name()
const override {
return _(
"Tilemap"); }
56 virtual void after_editor_set()
override;
58 virtual void update(
float dt_sec)
override;
72 void set(
int width,
int height,
const std::vector<unsigned int>& vec,
73 int z_pos,
bool solid);
77 void resize(
int newwidth,
int newheight,
int fill_id = 0,
78 int xoffset = 0,
int yoffset = 0);
81 int get_width()
const {
return m_width; }
82 int get_height()
const {
return m_height; }
83 Size get_size()
const {
return Size(m_width, m_height); }
85 void set_offset(
const Vector &offset_) { m_offset = offset_; }
86 Vector get_offset()
const {
return m_offset; }
88 void move_by(
const Vector& pos);
99 return Vector(m_movement.x, std::max(0.0f, m_movement.y));
106 {
return m_offset +
Vector(static_cast<float>(x), static_cast<float>(y)) * 32.0f; }
108 Rectf get_bbox()
const {
113 Rectf get_tile_bbox(
int x,
int y)
const {
122 int get_layer()
const {
return m_z_pos; }
123 void set_layer(
int layer_) { m_z_pos = layer_; }
125 bool is_solid()
const {
return m_real_solid && m_effective_solid; }
131 const Tile& get_tile(
int x,
int y)
const;
132 const Tile& get_tile_at(
const Vector& pos)
const;
133 uint32_t get_tile_id(
int x,
int y)
const;
134 uint32_t get_tile_id_at(
const Vector& pos)
const;
136 void change(
int x,
int y, uint32_t newtile);
138 void change_at(
const Vector& pos, uint32_t newtile);
141 void change_all(uint32_t oldtile, uint32_t newtile);
143 void set_flip(Flip flip) { m_flip = flip; }
144 Flip get_flip()
const {
return m_flip; }
149 void fade(
float alpha,
float seconds = 0);
163 void set_tileset(
const TileSet* new_tileset);
165 const std::vector<uint32_t>& get_tiles()
const {
return m_tiles; }
168 void update_effective_solid();
169 void float_channel(
float target,
float ¤t,
float remaining_time,
float dt_sec);
172 bool m_editor_active;
177 typedef std::vector<uint32_t> Tiles;
184 bool m_effective_solid;
196 float m_current_alpha;
197 float m_remaining_fade_time;
203 Color m_current_tint;
204 float m_remaining_tint_fade_time;
210 DrawingTarget m_draw_target;
Simple two dimensional vector.
Definition: vector.hpp:24
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
virtual void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: tilemap.cpp:183
void fade(float alpha, float seconds=0)
Start fading the tilemap to opacity given by alpha.
Definition: tilemap.cpp:586
Definition: object_settings.hpp:35
Vector get_tile_position(int x, int y) const
Returns the position of the upper-left corner of tile (x, y) in the sector.
Definition: tilemap.hpp:105
void tint_fade(const Color &new_tint, float seconds=0)
Start fading the tilemap to tint given by RGBA.
Definition: tilemap.cpp:593
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: tilemap.cpp:278
Vector get_movement(bool actual) const
Get the movement of this tilemap.
Definition: tilemap.hpp:94
Base class for all the things that make up Levels' Sectors.
Definition: game_object.hpp:46
void resize(int newwidth, int newheight, int fill_id=0, int xoffset=0, int yoffset=0)
resizes the tilemap to a new width and height (tries to not destroy the existing map) ...
Definition: tilemap.cpp:454
void set_solid(bool solid=true)
Changes Tilemap's solidity, i.e.
Definition: tilemap.cpp:520
void change_all(uint32_t oldtile, uint32_t newtile)
changes all tiles with the given ID
Definition: tilemap.cpp:573
float get_alpha() const
Return tilemap's opacity.
Definition: tilemap.cpp:609
Rect get_tiles_overlapping(const Rectf &rect) const
Returns the half-open rectangle of (x, y) tile indices that overlap the given rectangle in the sector...
Definition: tilemap.cpp:507
A class for all objects that contain / make use of a path.
Definition: path_object.hpp:28
void stop_moving()
Stop tilemap at next node.
Definition: tilemap.cpp:422
void set_alpha(float alpha)
Instantly switch tilemap's opacity to alpha.
Definition: tilemap.cpp:600
void goto_node(int node_no)
Move tilemap until at given node, then stop.
Definition: tilemap.cpp:408
void start_moving()
Start moving tilemap.
Definition: tilemap.cpp:415
This class is responsible for drawing the level tiles.
Definition: tilemap.hpp:39
Definition: reader_mapping.hpp:31
Definition: tile_set.hpp:42
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: tilemap.cpp:334
virtual void editor_update() override
Called each frame in the editor, used to keep linked objects together (e.g.
Definition: tilemap.cpp:321