-
Notifications
You must be signed in to change notification settings - Fork 4
Player Controller
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 Player Controller implements all user actions (building and removing towers mainly) and the effects with other elements ([game objects](Game Objects) and map),the player controller actions should be called from the Player class
Name | Version | Header | Implementation |
---|---|---|---|
Player Controller | 0.7.5 | player_controller.h | player_controller.cpp |
###Variables Private
-
map<pair<unsigned int,unsigned int>,tower_id> built_towers` all built towers positions and ids assigned in [game objects](Game Objects)
-
tower_set *towers
pointer to the [tower set](Tower Set) -
game_objects *objects
pointer to [game objects](Game Objects) -
tilemap *game_map
pointer to map
###Contructors
-
player_controller()
default constructor -
player_controller(tower_set &towers,game_objects &objects,tilemap &game_map)
full constructor
###Destructor
-
~player_controller()
clears all info, without destroying any spawned element
###Methods Public
-
unsigned int get_towers_size() const
return number of towers in [tower set](Tower Set) (all possible towers to build) -
set<string> get_tower_names() const
returns a set with all the towers names -
unsigned int spawned_towers() const
returns the number of spawned towers -
bool can_build(double x,double y) const
return true if a tower can be built in given position (position in map is empty and the tile is correct) -
bool build_tower(const string &name,double x,double y)` builds the tower with given name in given position
-
void remove_tower(double x,double y)
removes tower in given position (if any) -
bool is_tower(double x,double y) const
return true if there is a tower in given position -
tower* get_tower(double x,double y)
returns a pointer to the tower in given position (null if there is no tower) -
const tower *get_tower(double x,double y) const
returns a const pointer to tower in given position -
bool check() const
checks the class is working properly
Private
-
tower_id get_tower_id(double x,double y) const
returns the tower id in given position -
void remove_tower(tower_id)
removes the tower with given id -
pair<unsigned int,unsigned int> translate_position(double x,double y) const
converts position in pixels to tiles (in the current map) -
pair<double,double> translate_position(unsigned int x,unsigned int y) const
converts position in tiles to pixels (in the current map), returned position will be the center of the tile
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