|
LI2 Roguelite
|
#include <stdlib.h>#include <ncurses.h>#include "combat.h"#include "state.h"#include "map.h"#include "cell.h"#include "player.h"#include "monster.h"#include "item.h"#include "inventory.h"#include "menu.h"
Classes | |
| struct | projectile |
| (private) Structure of a thrown projectile More... | |
Typedefs | |
| typedef struct projectile | Projectile |
| (private) Structure of a thrown projectile More... | |
Functions | |
| Projectile * | initProjectile (int x, int y, int direction, int range, int effect, int damage, char symbol, int color) |
| Initializes a new projectile. More... | |
| void | moveProjectile (Projectile *p) |
| Moves a projectile. Reduces the number of turns left by 1. More... | |
| void | insertProjectile (Map *map, Projectile *p) |
| Inserts a projectile into the map. More... | |
| void | removeProjectile (Map *map, int index) |
| Removes a projectile from the map. More... | |
| void | explodeProjectile (State *st, Projectile *projectile) |
| Explodes a projectile. More... | |
| void | updateProjectile (State *st, Projectile *projectile, int index) |
| Updates a projectile within the game state. More... | |
| void | updateProjectiles (State *st) |
| void | freeProjectile (void *p) |
| void | throwRock (State *st) |
| Function to throw a rock projectile. More... | |
| void | throwSmokebomb (State *st) |
| Function to throw a smoke bomb projectile. More... | |
| void | throwFirebomb (State *st) |
| Function to throw a fire bomb projectile. More... | |
| void | throwIcebomb (State *st) |
| Function to throw an ice bomb projectile. More... | |
| void | throwProjectile (State *st) |
| void | drawProjectile (Projectile *p) |
| Draw a projectile. More... | |
| void | drawProjectiles (Map *map) |
| Draw all visible projectiles. More... | |
| void | killMonster (State *st, int x, int y) |
| Function to kill a monster with his coordinates. More... | |
| int | calculateDamage (int attack, int defense, int turn) |
| Calculates the damage of an attack. More... | |
| void | monsterAttacksPlayer (State *st, Monster *monster) |
| Function that attacks a player first. More... | |
| void | playerAttacksMonster (State *st, Monster *monster) |
| Function that attacks a monster first. More... | |
| typedef struct projectile Projectile |
(private) Structure of a thrown projectile
| x | The current x coordinate of the projectile |
| y | The current y coordinate of the projectile |
| direction | The ongoing direction of the projectile |
| turns_left | The number of turns left for the projectile to disappear/have an effect |
| effect | The effect of the projectile |
| damage | The damage of the projectile |
| color | The color of the projectile |
| 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
| attack | The attack of the attacker |
| defense | The defense of the defender |
| turn | The current turn |
| void drawProjectile | ( | Projectile * | p | ) |
Draw a projectile.
| p | Projectile to draw |
| void drawProjectiles | ( | Map * | map | ) |
Draw all visible projectiles.
| map | Map to draw visible projectiles |
| void explodeProjectile | ( | State * | st, |
| Projectile * | projectile | ||
| ) |
Explodes a projectile.
The explosion is a star shape with radius 5 Various effects are applied to the cells within the explosion
TODO: visual effects for monsters
| st | The game state |
| projectile | The projectile to explode |
| void freeProjectile | ( | void * | p | ) |
| Projectile* initProjectile | ( | int | x, |
| int | y, | ||
| int | direction, | ||
| int | range, | ||
| int | effect, | ||
| int | damage, | ||
| char | symbol, | ||
| int | color | ||
| ) |
Initializes a new projectile.
| x | The x coordinate of the projectile |
| y | The y coordinate of the projectile |
| direction | The direction of the projectile |
| range | The range of the projectile |
| effect | The effect of the projectile |
| damage | The damage of the projectile |
| symbol | The symbol of the projectile |
| color | The color of the projectile |
| void insertProjectile | ( | Map * | map, |
| Projectile * | p | ||
| ) |
Inserts a projectile into the map.
| map | The map to insert the projectile |
| p | The projectile to insert |
| 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
| 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 |
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.
| st | The game state |
| monster | The monster that attacks the player first |
| void moveProjectile | ( | Projectile * | p | ) |
Moves a projectile. Reduces the number of turns left by 1.
| p | The projectile to move |
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.
| st | The game state |
| monster | The monster that is attacked by the player first |
| void removeProjectile | ( | Map * | map, |
| int | index | ||
| ) |
Removes a projectile from the map.
| map | The map to remove the projectile |
| index | The index of the projectile in the map |
| void throwFirebomb | ( | State * | st | ) |
Function to throw a fire bomb projectile.
The fire bomb is thrown in the direction the player is facing The fire bomb is thrown until it hits a wall or a monster
| st | The game state |
| void throwIcebomb | ( | State * | st | ) |
Function to throw an ice bomb projectile.
The ice bomb is thrown in the direction the player is facing The ice bomb is thrown until it hits a wall or a monster
| st | The game state |
| void throwProjectile | ( | State * | st | ) |
| 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
| st | The game state |
| void throwSmokebomb | ( | State * | st | ) |
Function to throw a smoke bomb projectile.
The smoke bomb is thrown in the direction the player is facing The smoke bomb is thrown until it hits a wall or a monster
| st | The game state |
| void updateProjectile | ( | State * | st, |
| Projectile * | projectile, | ||
| int | index | ||
| ) |
Updates a projectile within the game state.
| st | The game state |
| projectile | The projectile to update |
| index | The index of the projectile in the map |
| void updateProjectiles | ( | State * | st | ) |