Go to the source code of this file.
◆ MAX_HEALTH
maximum health of the player
◆ PLAYER_COLOR
| #define PLAYER_COLOR COLOR_WHITE |
default color of the player
◆ PLAYER_EARING_PROB
| #define PLAYER_EARING_PROB 30 |
probability of hearing a close monster when a player moves (in %)
◆ PLAYER_EARING_RANGE_CLOSE
| #define PLAYER_EARING_RANGE_CLOSE 10 |
range of hearing a close monster (cells)
◆ PLAYER_EARING_RANGE_FAR
| #define PLAYER_EARING_RANGE_FAR 40 |
range of hearing a far monster (cells)
◆ PLAYER_STARTING_ATTACK
| #define PLAYER_STARTING_ATTACK 5 |
starting attack of the player
◆ PLAYER_STARTING_DEFENSE
| #define PLAYER_STARTING_DEFENSE 2 |
starting defense of the player
◆ PLAYER_SYMBOL
| #define PLAYER_SYMBOL '@' |
default symbol of the player
◆ PLAYER_VISION
range of the vision of the player (cells)
◆ PLAYER_VISION_WIDTH
| #define PLAYER_VISION_WIDTH 1 |
width of the player's vision (cells)
◆ Inventory
◆ Player
Structure of a player.
A player is a singular game unit with 2D coordinates, a symbol, a health, a defense, an attack, a vision and more. TODO
- Parameters
-
| symbol | Character to be displayed on the screen |
| x | player x coordinate |
| y | player y coordinate |
| health | Health of the player |
| max_health | Maximum health of the player set to MAX_HEALTH macro |
| defense | Defense of the player |
| attack | Attack of the player |
| vision | Vision of the player in cells |
| vision_width | Vision width of the player in cells |
| earing_range_close | Earling range of the player in cells |
| earing_range_far | Earling range of the player in cells |
| earing_prob | Probability of hearing a close monster when a player moves (in %) |
| sensory_potion_turns | Number of turns the player has sensory potion effect |
| potion_invincibility_turns | Number of turns the player has invincibility potion effect |
| direction | Direction of the player (used for throwing projectiles) |
| color | Color of the player changes when he takes damage or uses a potion |
| inventory | Inventory of the player |
◆ drawPlayer()
Draws the player on the screen.
TODO: colors damage the player and add color to player
- Parameters
-
- Returns
- void
◆ freePlayer()
| void freePlayer |
( |
void * |
p | ) |
|
frees the player. Sets all fields to 0 and frees the memory.
- Parameters
-
- Returns
- void
◆ initPlayer()
| Player* initPlayer |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Initializes a new player. Allocates memory for a new player and initializes its fields.
- Parameters
-
| x | Player x initial coordinate |
| y | Player y initial coordinate |
- Returns
- Player* Initialized player at (x,y)
◆ updatePotionEffects()
| void updatePotionEffects |
( |
Player * |
p | ) |
|
Updates the potion effects of the player.
Sensory potion: increases the player vision and earing Invincibility potion: increases the player defense
- Parameters
-
- Returns
- void