Go to the source code of this file.
◆ MAX_PROJECTILES
| #define MAX_PROJECTILES 20 |
◆ Map
◆ Monster
◆ Projectile
◆ State
◆ calculateDamage()
| int calculateDamage |
( |
int |
attack, |
|
|
int |
defense, |
|
|
int |
turn |
|
) |
| |
Calculates the damage of an attack.
If the st->turn % 5 == 0 the attack is a critical hit attack = attack * 1.5 1.5 is the critical hit multiplier 5 is the number of turns between critical hits
NOTE: Per example a potion of strength could increase the critical hit multiplier, or reduce the number of turns between critical hits.
The damage is calculated with the formula: damage = attack * (100 - defense) / 100
- Parameters
-
| attack | The attack of the attacker |
| defense | The defense of the defender |
| turn | The current turn |
- Returns
- int The damage of the attack to retrieved from the defender health
◆ drawProjectiles()
| void drawProjectiles |
( |
Map * |
map | ) |
|
Draw all visible projectiles.
- Parameters
-
| map | Map to draw visible projectiles |
◆ freeProjectile()
| void freeProjectile |
( |
void * |
p | ) |
|
◆ killMonster()
| void killMonster |
( |
State * |
st, |
|
|
int |
x, |
|
|
int |
y |
|
) |
| |
Function to kill a monster with his coordinates.
The monster is removed from the map and the monsters array
- Parameters
-
| st | The game state |
| x | The x coordinate of the monster |
| y | The y coordinate of the monster TODO: change to monster instead of coordinates |
◆ monsterAttacksPlayer()
Function that attacks a player first.
First the monster attacks the player, then the player attacks the monster. If the monster dies, the player earns gold and the monster is removed from the map. If the player dies, the game is over. A message is sent to the menu to be displayed in either case.
- Parameters
-
| st | The game state |
| monster | The monster that attacks the player first |
◆ playerAttacksMonster()
Function that attacks a monster first.
First the player attacks the monster, then the monster attacks the player. Similar to monsterAttacksPlayer(State *st, Monster *monster) function.
- Parameters
-
| st | The game state |
| monster | The monster that is attacked by the player first |
◆ throwProjectile()
| void throwProjectile |
( |
State * |
st | ) |
|
◆ throwRock()
| void throwRock |
( |
State * |
st | ) |
|
Function to throw a rock projectile.
The rock is thrown in the direction the player is facing The rock is thrown until it hits a wall or a monster Update projectile position with moveProjectiles function
- Parameters
-
- Returns
- void
◆ updateProjectiles()
| void updateProjectiles |
( |
State * |
st | ) |
|