-
Notifications
You must be signed in to change notification settings - Fork 4
Tower
Not the ones where Altair jumps
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 Defines an instance of a player tower, with given [tower attributes](Tower Attributes),a player can build a tower if has enough coins, the tower will attack enemies. A tower is a child class of [game object](Game Object) and it will have a position and an active boolean value, tower will be drawn centered in the bottom of the given tile, a tower will spawn [attacks](Tower Attack). The player can also remove a tower, and will receive a percentage of the original cost.
Name | Version | Header | Implementation |
---|---|---|---|
Tower | 0.7.6 | tower.h | tower.cpp |
Example of tower | CCLicense by nicubunu
Before reading this, make sure you have read the pages about [Game Object](Game Object),[Tower Attack Attributes](Tower Attack Attributes),[Tower Attack](Tower Attack) and [Tower Attributes](Tower Attributes)
###Variables Private
-
tower_attributes *attributes
[attributes](Tower Attributes) of instanced tower -
unsigned int atk_counter
time to next attack (in frames) -
unsigned int atk_delay
time between attack (in frames) -
const ALLEGRO_TIMER *timer
timer used to update tower and instantiate [tower attacks](Tower Attack)
###Constructors
-
tower()
default constructor -
tower(const tower_attributes &attributes,double posx,double posy,const ALLEGRO_TIMER *timer)
full constructor
###Destructor
~tower()
###Methods Public
-
string get_name() const
returns tower name -
unsigned int get_range() const
returns tower range (in pixels) -
unsigned int get_damage()const
returns tower attack damage -
unsigned int get_cost() const
returns prize of the tower (in gold or bit-coins) -
atk_type get_attack_type() const
returns attack type -
bool in_range(pair<double,double> target) const
return true if position given is in range -
bool can_attack()const
return true if tower can attack (counter reached 0) -
void update()
update tower timers if active (call each frame) -
void draw() const
draw tower -
tower_atk attack(const pair<double,double> target)
spawn an attack with given position as target -
bool check() const
check class is working properly, returns false if not
Private
-
void set_delay()
sets delay of attack -
void reset_counter()
resets attack counter
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