generated from pimoroni/picosystem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapGenerator.h
60 lines (48 loc) · 1.13 KB
/
MapGenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <stdint.h>
#include "Map.h"
class MapGenerator
{
public:
static void Generate();
private:
struct NeighbourInfo
{
union
{
uint8_t mask;
struct
{
bool hasNorth : 1;
bool hasEast : 1;
bool hasSouth : 1;
bool hasWest : 1;
bool canDemolishNorth : 1;
bool canDemolishEast : 1;
bool canDemolishSouth : 1;
bool canDemolishWest : 1;
};
};
uint8_t count;
bool IsCorner() const
{
if (count != 2)
return false;
if (hasNorth && hasEast)
return true;
if (hasEast && hasSouth)
return true;
if (hasSouth && hasWest)
return true;
if (hasWest && hasNorth)
return true;
return false;
}
};
static uint8_t CountNeighbours(uint8_t x, uint8_t y);
static uint8_t CountImmediateNeighbours(uint8_t x, uint8_t y);
static NeighbourInfo GetRoomNeighbourMask(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
static void SplitMap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t doorX, uint8_t doorY);
static NeighbourInfo GetCellNeighbourInfo(uint8_t x, uint8_t y);
static uint8_t GetDistanceToCellType(uint8_t x, uint8_t y, CellType cellType);
};