LI2 Roguelite
Classes | Macros | Typedefs | Functions
player.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  player
 Structure of a player. More...
 

Macros

#define PLAYER_SYMBOL   '@'
 default symbol of the player More...
 
#define PLAYER_COLOR   COLOR_WHITE
 default color of the player More...
 
#define MAX_HEALTH   100
 maximum health of the player More...
 
#define PLAYER_STARTING_ATTACK   5
 starting attack of the player More...
 
#define PLAYER_STARTING_DEFENSE   2
 starting defense of the player More...
 
#define PLAYER_VISION   10
 range of the vision of the player (cells) More...
 
#define PLAYER_VISION_WIDTH   1
 width of the player's vision (cells) More...
 
#define PLAYER_EARING_RANGE_CLOSE   10
 range of hearing a close monster (cells) More...
 
#define PLAYER_EARING_RANGE_FAR   40
 range of hearing a far monster (cells) More...
 
#define PLAYER_EARING_PROB   30
 probability of hearing a close monster when a player moves (in %) More...
 

Typedefs

typedef struct inventory Inventory
 
typedef struct player Player
 Structure of a player. More...
 

Functions

PlayerinitPlayer (int x, int y)
 Initializes a new player. Allocates memory for a new player and initializes its fields. More...
 
void updatePotionEffects (Player *p)
 Updates the potion effects of the player. More...
 
void drawPlayer (Player *p)
 Draws the player on the screen. More...
 
void freePlayer (void *p)
 frees the player. Sets all fields to 0 and frees the memory. More...
 

Macro Definition Documentation

◆ MAX_HEALTH

#define MAX_HEALTH   100

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

#define PLAYER_VISION   10

range of the vision of the player (cells)

◆ PLAYER_VISION_WIDTH

#define PLAYER_VISION_WIDTH   1

width of the player's vision (cells)

Typedef Documentation

◆ Inventory

typedef struct inventory Inventory

◆ Player

typedef struct player 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
symbolCharacter to be displayed on the screen
xplayer x coordinate
yplayer y coordinate
healthHealth of the player
max_healthMaximum health of the player set to MAX_HEALTH macro
defenseDefense of the player
attackAttack of the player
visionVision of the player in cells
vision_widthVision width of the player in cells
earing_range_closeEarling range of the player in cells
earing_range_farEarling range of the player in cells
earing_probProbability of hearing a close monster when a player moves (in %)
sensory_potion_turnsNumber of turns the player has sensory potion effect
potion_invincibility_turnsNumber of turns the player has invincibility potion effect
directionDirection of the player (used for throwing projectiles)
colorColor of the player changes when he takes damage or uses a potion
inventoryInventory of the player

Function Documentation

◆ drawPlayer()

void drawPlayer ( Player p)

Draws the player on the screen.

TODO: colors damage the player and add color to player

Parameters
pPlayer to draw
Returns
void

◆ freePlayer()

void freePlayer ( void *  p)

frees the player. Sets all fields to 0 and frees the memory.

Parameters
pPlayer to free
Returns
void

◆ initPlayer()

Player* initPlayer ( int  x,
int  y 
)

Initializes a new player. Allocates memory for a new player and initializes its fields.

Parameters
xPlayer x initial coordinate
yPlayer 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
pPlayer to update
Returns
void