Dungeonator  1.0.0
a dungeon generator library
Data Structures | Macros | Typedefs | Functions
rooms.h File Reference

code for placing and detecting collisions of rooms More...

#include "util.h"
#include "grid.h"

Go to the source code of this file.

Data Structures

struct  Rooms
 

Macros

#define ROOMS_ALLOC_SIZE   20
 

Typedefs

typedef struct Rooms Room
 

Functions

bool isOverlapping (Room *A, Room *B)
 
bool placeRoomsInGrid (Grid *grid, regions_t regions, int tries, int roomAddSize, int *region)
 

Detailed Description

code for placing and detecting collisions of rooms

Macro Definition Documentation

◆ ROOMS_ALLOC_SIZE

#define ROOMS_ALLOC_SIZE   20

the default allocation size for the array of rooms, can be overrided

Typedef Documentation

◆ Room

typedef struct Rooms Room

a struct to represent a room, used to determine overlapping

Function Documentation

◆ isOverlapping()

bool isOverlapping ( Room A,
Room B 
)

test if two rooms are overlapping

Parameters
[in]Aa pointer to the frist room to test
[in]Ba pointer to the second room to test
Returns
if the rooms are overlapping

◆ placeRoomsInGrid()

bool placeRoomsInGrid ( Grid grid,
regions_t  regions,
int  tries,
int  roomAddSize,
int *  region 
)

place rooms in a grid so that they don't overlap, and fill in their respective regions

Parameters
[in,out]gridthe grid to put the rooms onto
[in,out]regionsthe regions to place the rooms' regions onto
[in]triesthe number of tries to places the rooms
[in]roomAddSizelarger = bigger rooms
[in,out]regiona pointer to the region counter to determine the current region - will be mutated
Returns
bool if the placing was successful (can fail on out of memory)