supertux
|
This class is responsible for managing an array of tiles. More...
#include <tilemap.hpp>
Public Types | |
enum | AutotileCornerOperation { ADD_TOP_LEFT, ADD_TOP_RIGHT, ADD_BOTTOM_LEFT, ADD_BOTTOM_RIGHT, REMOVE_TOP_LEFT, REMOVE_TOP_RIGHT, REMOVE_BOTTOM_LEFT, REMOVE_BOTTOM_RIGHT } |
Public Member Functions | |
TileMap (const TileSet *tileset) | |
TileMap (const TileSet *tileset, const ReaderMapping &reader) | |
virtual void | finish_construction () override |
Called after all objects have been added to the Sector and the Sector is fully constructed. More... | |
virtual std::string | get_class_name () const override |
virtual std::string | get_exposed_class_name () const override |
virtual const std::string | get_icon_path () const override |
virtual std::string | get_display_name () const override |
Returns the display name of the object, translated to the user's locale. | |
virtual GameObjectClasses | get_class_types () const override |
List notable classes in inheritance hierarchy of class. More... | |
virtual ObjectSettings | get_settings () override |
virtual void | after_editor_set () override |
void | save_state () override |
Save/check the current state of the object. More... | |
void | check_state () override |
virtual void | update (float dt_sec) override |
This function is called once per frame and allows the object to update it's state. More... | |
virtual void | draw (DrawingContext &context) override |
The GameObject should draw itself onto the provided DrawingContext if this function is called. More... | |
virtual void | editor_update () override |
Called each frame in the editor, used to keep linked objects together (e.g. More... | |
virtual void | on_flip (float height) override |
When level is flipped vertically. | |
void | set (int width, int height, const std::vector< unsigned int > &vec, int z_pos, bool solid) |
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) | |
void | resize (const Size &newsize, const Size &resize_offset) |
int | get_width () const |
int | get_height () const |
Size | get_size () const |
void | set_offset (const Vector &offset_) |
Vector | get_offset () const |
void | set_ground_movement_manager (const std::shared_ptr< CollisionGroundMovementManager > &movement_manager) |
void | move_by (const Vector &pos) |
Vector | get_movement (bool actual) const |
Get the movement of this tilemap. More... | |
Vector | get_tile_position (int x, int y) const |
Returns the position of the upper-left corner of tile (x, y) in the sector. More... | |
Rectf | get_bbox () const |
Rectf | get_tile_bbox (int x, int y) const |
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. More... | |
void | hits_object_bottom (CollisionObject &object) |
Called by the collision mechanism to indicate that this tilemap has been hit on the top, i.e. More... | |
void | notify_object_removal (CollisionObject *other) |
int | get_layer () const |
void | set_layer (int layer) |
bool | is_solid () const |
void | set_solid (bool solid=true) |
Switches the tilemap's real solidity to ""solid"". More... | |
bool | is_outside_bounds (const Vector &pos) const |
const Tile & | get_tile (int x, int y) const |
const Tile & | get_tile_at (const Vector &pos) const |
uint32_t | get_tile_id (int x, int y) const |
Returns the ID of the tile at the given coordinates or 0 if out of bounds. More... | |
uint32_t | get_tile_id_at (float x, float y) const |
Returns the ID of the tile at the given position (in world coordinates). More... | |
uint32_t | get_tile_id_at (const Vector &pos) const |
void | change (int x, int y, uint32_t newtile) |
Changes the tile at the given coordinates to ""newtile"". More... | |
void | change_at (float x, float y, uint32_t newtile) |
Changes the tile at the given position (in-world coordinates) to ""newtile"". More... | |
void | change_at (const Vector &pos, uint32_t newtile) |
void | change_all (uint32_t oldtile, uint32_t newtile) |
Changes all tiles with the given ID. More... | |
void | autotile (int x, int y, uint32_t tile) |
Puts the correct autotile block at the given position. | |
void | autotile_corner (int x, int y, uint32_t tile, AutotileCornerOperation op) |
Puts the correct autotile blocks at the tiles around the given corner. | |
void | autotile_erase (const Vector &pos, const Vector &corner_pos) |
Erases in autotile mode. | |
AutotileSet * | get_autotileset (uint32_t tile) const |
Returns the Autotileset associated with the given tile. | |
void | set_flip (Flip flip) |
Flip | get_flip () const |
void | fade (float alpha, float time) |
Starts fading the tilemap to the opacity given by ""alpha"". More... | |
void | tint_fade (const Color &new_tint, float time=0.f) |
Start fading the tilemap to tint given by RGBA. More... | |
void | tint_fade (float time, float red, float green, float blue, float alpha) |
Starts fading the tilemap to tint given by RGBA. More... | |
Color | get_current_tint () const |
void | set_alpha (float alpha) |
Instantly switches the tilemap's opacity to ""alpha"". More... | |
float | get_alpha () const |
Returns the tilemap's opacity. More... | |
float | get_target_alpha () const |
void | set_tileset (const TileSet *new_tileset) |
const std::vector< uint32_t > & | get_tiles () const |
![]() | |
GameObject (const std::string &name) | |
GameObject (const ReaderMapping &reader) | |
UID | get_uid () const |
virtual void | save (Writer &writer) |
This function saves the object. More... | |
std::string | save () |
virtual std::vector< std::string > | get_patches () const |
Version checking/updating, patch information. | |
virtual void | update_version () |
int | get_version () const |
Returns the current version of the object. | |
int | get_latest_version () const |
Returns the latest version of the object. | |
bool | is_up_to_date () const |
Checks whether the object's current version is equal to its latest one. | |
virtual bool | is_singleton () const |
If true only a single object of this type is allowed in a given GameObjectManager. | |
virtual bool | has_variable_size () const |
Does this object have variable size (secret area trigger, wind, etc.) | |
virtual bool | is_saveable () const |
Indicates if the object will be saved. More... | |
virtual bool | track_state () const |
Indicates if the object's state should be tracked. More... | |
virtual bool | has_object_manager_priority () const |
Indicates if the object should be added at the beginning of the object list. More... | |
virtual bool | has_settings () const |
Indicates if get_settings() is implemented. More... | |
virtual GameObjectTypes | get_types () const |
Get all types of the object, if available. More... | |
int | get_type () const |
Returns the type index of the object. | |
virtual void | remove_me () |
schedules this object to be removed at the end of the frame | |
bool | is_valid () const |
returns true if the object is not scheduled to be removed yet | |
void | add_remove_listener (ObjectRemoveListener *listener) |
registers a remove listener which will be called if the object gets removed/destroyed | |
void | del_remove_listener (ObjectRemoveListener *listener) |
unregisters a remove listener, so it will no longer be called if the object gets removed/destroyed | |
void | set_name (const std::string &name) |
const std::string & | get_name () const |
Returns the name of the object. | |
virtual void | stop_looping_sounds () |
stops all looping sounds | |
virtual void | play_looping_sounds () |
continues all looping sounds | |
template<typename T > | |
T * | get_component () |
void | add_component (std::unique_ptr< GameObjectComponent > component) |
void | remove_component (GameObjectComponent *component) |
virtual void | editor_delete () |
The editor requested the deletion of the object. | |
virtual void | editor_select () |
The user clicked on the object in the editor and selected it. | |
virtual void | editor_deselect () |
The object got deselected. | |
GameObjectManager * | get_parent () const |
![]() | |
void | init_path (const ReaderMapping &mapping, bool running_default) |
For compatibilty reasons this needs to get the GameObjects main mapping, not the (path ...) mapping. | |
void | init_path_pos (const Vector &pos, bool running=false) |
PathGameObject * | get_path_gameobject () const |
Path * | get_path () const |
PathWalker * | get_walker () const |
void | editor_clone_path (PathGameObject *path_object) |
std::string | get_path_ref () const |
void | editor_set_path_by_ref (const std::string &new_ref) |
void | goto_node (int node_idx) |
Moves the path object until at given node, then stops. More... | |
void | set_node (int node_idx) |
Jumps instantly to the given node. More... | |
void | start_moving () |
Starts moving the path object automatically. | |
void | stop_moving () |
Stops moving the path object. | |
Static Public Member Functions | |
static void | register_class (ssq::VM &vm) |
static std::string | class_name () |
static std::string | display_name () |
![]() | |
static void | register_class (ssq::VM &vm) |
Public Attributes | |
bool | m_editor_active |
Additional Inherited Members | |
![]() | |
enum | TypeChange { INITIAL = -1 } |
When the type has been changed from the editor. More... | |
![]() | |
void | parse_type (const ReaderMapping &reader) |
Parse object type. More... | |
virtual void | on_type_change (int old_type) |
int | type_id_to_value (const std::string &id) const |
Conversion between type ID and value. More... | |
std::string | type_value_to_id (int value) const |
![]() | |
void | save_state () const |
void | check_state () const |
void | on_flip () |
![]() | |
static void | register_members (ssq::Class &cls) |
![]() | |
std::string | m_name |
a name for the gameobject, this is mostly a hint for scripts and for debugging, don't rely on names being set or being unique | |
int | m_type |
Type of the GameObject. More... | |
std::vector< std::unique_ptr< FadeHelper > > | m_fade_helpers |
Fade Helpers are for easing/fading script functions. | |
bool | m_track_undo |
Track the following creation/deletion of this object for undo. More... | |
![]() | |
PathWalker::Handle | m_path_handle |
This class is responsible for managing an array of tiles.
A ""TileMap"" that was given a name can be controlled by scripts. The tilemap can be moved by specifying a path for it. A ""TileMap"" is instantiated by placing a definition inside a level. It can then be accessed by its name from a script or via ""sector.name"" from the console.
void TileMap::change | ( | int | x, |
int | y, | ||
uint32_t | newtile | ||
) |
Changes the tile at the given coordinates to ""newtile"".
The origin is at the top left.
int | $x | |
int | $y | |
int | $newtile |
void TileMap::change_all | ( | uint32_t | oldtile, |
uint32_t | newtile | ||
) |
Changes all tiles with the given ID.
int | $oldtile | |
int | $newtile |
void TileMap::change_at | ( | float | x, |
float | y, | ||
uint32_t | newtile | ||
) |
Changes the tile at the given position (in-world coordinates) to ""newtile"".
float | $x | |
float | $y | |
int | $newtile |
|
overridevirtual |
The GameObject should draw itself onto the provided DrawingContext if this function is called.
Implements GameObject.
|
overridevirtual |
Called each frame in the editor, used to keep linked objects together (e.g.
platform on a path)
Reimplemented from GameObject.
void TileMap::fade | ( | float | alpha, |
float | time | ||
) |
Starts fading the tilemap to the opacity given by ""alpha"".
Destination opacity will be reached after ""time"" seconds. Also influences solidity.
float | $alpha | |
float | $time |
|
overridevirtual |
Called after all objects have been added to the Sector and the Sector is fully constructed.
If objects refer to other objects by name, those connection can be resolved here.
Reimplemented from GameObject.
float TileMap::get_alpha | ( | ) | const |
Returns the tilemap's opacity.
${SRG_TABLENEWPARAGRAPH} Note: While the tilemap is fading in or out, this will return the current alpha value, not the target alpha.
|
inlineoverridevirtual |
List notable classes in inheritance hierarchy of class.
This makes it possible to efficiently look up all objects deriving from a particular intermediate class
Reimplemented from GameObject.
|
inline |
Get the movement of this tilemap.
The collision detection code may need a non-negative y-movement. Passing `false' as the `actual' argument will provide that. Used exclusively in src/supertux/sector.cpp.
uint32_t TileMap::get_tile_id | ( | int | x, |
int | y | ||
) | const |
Returns the ID of the tile at the given coordinates or 0 if out of bounds.
The origin is at the top left.
int | $x | |
int | $y |
uint32_t TileMap::get_tile_id_at | ( | float | x, |
float | y | ||
) | const |
Returns the ID of the tile at the given position (in world coordinates).
float | $x | |
float | $y |
|
inline |
Returns the position of the upper-left corner of tile (x, y) in the sector.
Returns the half-open rectangle of (x, y) tile indices that overlap the given rectangle in the sector.
void TileMap::hits_object_bottom | ( | CollisionObject & | object | ) |
Called by the collision mechanism to indicate that this tilemap has been hit on the top, i.e.
has hit a moving object on the bottom of its collision rectangle.
|
overridevirtual |
Save/check the current state of the object.
Reimplemented from GameObject.
void TileMap::set_alpha | ( | float | alpha | ) |
Instantly switches the tilemap's opacity to ""alpha"".
Also influences solidity.
float | $alpha |
void TileMap::set_solid | ( | bool | solid = true | ) |
Switches the tilemap's real solidity to ""solid"".
${SRG_TABLENEWPARAGRAPH} Note: The effective solidity is also influenced by the alpha of the tilemap.
bool | $solid |
void TileMap::tint_fade | ( | const Color & | new_tint, |
float | time = 0.f |
||
) |
Start fading the tilemap to tint given by RGBA.
Destination opacity will be reached after seconds
seconds. Doesn't influence solidity.
void TileMap::tint_fade | ( | float | time, |
float | red, | ||
float | green, | ||
float | blue, | ||
float | alpha | ||
) |
Starts fading the tilemap to tint given by RGBA.
Destination opacity will be reached after ""time"" seconds. Doesn't influence solidity.
float | $time | |
float | $red | |
float | $green | |
float | $blue | |
float | $alpha |
|
overridevirtual |
This function is called once per frame and allows the object to update it's state.
The dt_sec is the time that has passed since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode). This function is not called in the Editor.
Implements GameObject.