-
Notifications
You must be signed in to change notification settings - Fork 4
Tile
This Documentation is from a code still under heavy development, you may find errors,sudden changes or the answer to life,universe and everything
###Overview Maps in Don't Crush My Castle are Tilemaps, this means that all the map is composed by simple images (called Tiles), each tile define a squared bitmap that will be used to draw the tile and a type that will define the kind of tile, also, each tile has an id defined in his Tileset.
Name | Version | Header | Implementation |
---|---|---|---|
Tile | 0.7.6 | tile.h | tile.cpp |
Types of Tiles
Tiles are defined with a tile_type enum (See Reference), which defines the behaviour of the tile in-game, the different types are:
- blocked: defines a tile where it is not allowed to build anything, enemies can't pass through blocked tiles
- road: defines a tile where player can't build anything, enemies will pass through these tiles, and there must be a connection of road tiles between spawner and castle (this may change in the future)
- ground: player can build towers on these tiles and enemies won't walk over ground tiles (this may change in the future, with two different ground tiles)
- open_ground: player can build towers and enemies can move through empty tiles
- special: defines a special tile which will be handled in a special way, not behaviour is defined
- null_tile: (default value)tile with no behaviour assigned,usually this type is assigned in case of error when creating or loading tiles (for a correct use of tiles with no behaviour assigned, special type should be used)
Example of 3 tiles (road,ground and blocked) | under CCLicense by George_
###Variables Public
-
tile_type type
defines the type of tile (blocked,road,special,open_ground or null_tile) as a tile_type enum (See Reference)
Private
-
ALLEGRO_BITMAP* bitmap
pointer to the bitmap (allegro_bitmap) that will be used to draw the tile, class tile will ensure that only one tile points to the same bitmap, copying bitmap when creating a new tile and destroying it when necessary
###Constructors
-
tile()
default constructor, defines a tile with null type -
tile(tile_type type,const ALLEGRO_BITMAP *bitmap)
constructor with type and bitmap, will resize given bitmap if width and height are different (to the lower value), note that this will create a new bitmap -
tile(tile_type type,const ALLEGRO_BITMAP *bitmap,unsigned int width)
same as full constructor, but will always resize bitmap to a square of given width -
tile(const tile &other)
copy constructor, will create a new tile and copy the bitmap (so both tiles will point to a different bitmap)
###Destructor
-
~tile()
will destroy the tile bitmap
###Methods Public
-
void resize(unsigned int width)
resize the bitmap of the tile to the given width (height will be the same) -
void draw(float x,float y) const
draws tile in x,y position (this method uses al_draw_bitmap, so the tile will be drawn on the target bitmap defined by al_set_target_bitmap) -
draw_resized(float x,float y,unsigned int width) const
same as draw, but it will resize the bitmap to given size before drawing, the resize will only be used for the drawn bitmap, the original bitmap will not be changed. note that this function have worse performance that draw -
unsigned int size() const
returns the bitmap width (same as height) -
bool check() const
will check if the bitmap is correct (there is a not null bitmap and is a squared bitmap), return true if everything is fine
###Operators
-
tile& operator=(const tile &other)
assignment operator, will copy the bitmap of other into a new one (avoiding multiple tiles pointing to same bitmap), also, will destroy any bitmap before copying the new one
Don't Crush My Castle Wiki is under CC License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
_______________________
/ Don't Crush My Castle \
\ is a cool name /
-----------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
DCmC Wiki 0.7.6
- [Home] (Home)
- [Getting Started] (Getting Started)
- Documentation
- Reference
- Attributions