Ludum Dare 29
HackSoc's entry for the Ludum Dare Jam 29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
level.c File Reference
#include <curses.h>
#include <stdlib.h>
#include "level.h"
#include "mob.h"
#include "utils.h"
#include "effect.h"
#include "list.h"
#include "player.h"
Include dependency graph for level.c:

Macros

#define DEF_MOB(sym, n, col, hlth)
 

Functions

static void place_cell (Level *level, unsigned int x, unsigned int y, Cell *to_place, bool careful)
 
static void mine_level (Level *level, unsigned int num_miners, unsigned int spread, unsigned int iterations, unsigned int startx, unsigned int starty, Cell *to_place, bool make_stairs)
 
static void add_mob (Level *level)
 
void build_level (Level *level)
 
void do_affliction (Mob *mob)
 
void run_turn (Level *level)
 
static void calculate_illumination (Level *level)
 
void display_level (Level *level)
 

Variables

bool quit
 
static const struct Mob default_mobs []
 

Macro Definition Documentation

#define DEF_MOB (   sym,
  n,
  col,
  hlth 
)
Value:
{.symbol = (sym), .colour = (col), .name = (n), \
.is_bold = false, .hostile = true, .health = (hlth), .max_health = (hlth), \
.level = NULL, .moblist = {.next = NULL, .prev=NULL}, .turn_action = NULL, \
.xpos = 0, .ypos = 0, .score = 0, .darksight = true, .luminosity = 0}

Function Documentation

static void add_mob ( Level level)
static

Add a mob to a level.

Parameters
levelThe level to add to.

Here is the call graph for this function:

Here is the caller graph for this function:

void build_level ( Level level)

Initialises a level.

Parameters
levelLevel to initialise.

Here is the call graph for this function:

Here is the caller graph for this function:

static void calculate_illumination ( Level level)
static

Calculate which cells are illuminated or not

Parameters
levelThe level to check

Here is the call graph for this function:

Here is the caller graph for this function:

void display_level ( Level level)

Render the level to the screen. The symbol for a level is picked according to the following priorities: occupant > top item > base.

Parameters
levelGrid to display.

Here is the call graph for this function:

Here is the caller graph for this function:

void do_affliction ( Mob mob)

Run afflicated routines on a mob.

Parameters
mobAfflicted mob.

Here is the call graph for this function:

Here is the caller graph for this function:

static void mine_level ( Level level,
unsigned int  num_miners,
unsigned int  spread,
unsigned int  iterations,
unsigned int  startx,
unsigned int  starty,
Cell to_place,
bool  make_stairs 
)
static

Mine out the level. All miners get placed in the same starting coordinates, and then are spread out, before being free to wander around as they see fit.

Parameters
levelThe level to mine
num_minersThe number of miners to place.
spreadThe maximum distance to spread out the miners.
iterationsThe number of steps to mine.
startxThe X coordinate to position the miners (before spreading).
startyThe Y coordinate to position the miners (before spreading).
to_placeThe cell to place.
make_stairsIf true, place the stairs at one of the miners randomly.

Here is the call graph for this function:

Here is the caller graph for this function:

static void place_cell ( Level level,
unsigned int  x,
unsigned int  y,
Cell to_place,
bool  careful 
)
static

(Shallow) Clone a cell and place it in the given position. Mobs and items in the cell are NOT cloned, those pointers get shared.

Parameters
levelThe level to place the cell in.
xThe X coordinate.
yThe Y coordinate.
to_placeThe cell to clone.
carefulOnly place if the space is occuped by a wall or floor.

Here is the caller graph for this function:

void run_turn ( Level level)

A "turn" consists of all of the mobs acting once, possibly followed by some constant effect on the mob. As the player is a turn, this is (indirectly) where blocking for input happens.

Parameters
levelThe level grid to run the turn on.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const struct Mob default_mobs[]
static
Initial value:
= {
DEF_MOB('H', "Hedgehog", COLOR_YELLOW, 5),
}
#define DEF_MOB(sym, n, col, hlth)
Definition: level.c:140
bool quit

Whether to quit the game or not.