Labyrinth of the Minotaur A simple roguelike/RPG using a nokia 5110 screen

Dependencies:   N5110 PowerControl mbed

Committer:
ThomasBGill
Date:
Mon May 11 22:25:57 2015 +0000
Revision:
36:b64696135142
Parent:
35:2c290fa78f1d
Child:
37:a0ea57af9279
Version 1.0 finished

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasBGill 35:2c290fa78f1d 1 /**
ThomasBGill 35:2c290fa78f1d 2 * @file WorldBuilder.h
ThomasBGill 35:2c290fa78f1d 3 * @brief Header file containing the world generation member functions and variables
ThomasBGill 35:2c290fa78f1d 4 * @brief Revision 1.0
ThomasBGill 35:2c290fa78f1d 5 *
ThomasBGill 35:2c290fa78f1d 6 * @author Thomas Barnaby Gill
ThomasBGill 35:2c290fa78f1d 7 * @date 11th May 2015
ThomasBGill 35:2c290fa78f1d 8 */
ThomasBGill 35:2c290fa78f1d 9
ThomasBGill 20:e54792b89571 10 #include "mbed.h"
ThomasBGill 20:e54792b89571 11
ThomasBGill 20:e54792b89571 12 #ifndef WORLDBUILDER_H
ThomasBGill 20:e54792b89571 13 #define WORLDBUILDER_H
ThomasBGill 20:e54792b89571 14
ThomasBGill 20:e54792b89571 15 #define WALL 0
ThomasBGill 20:e54792b89571 16 #define FLOOR 1
ThomasBGill 20:e54792b89571 17 #define ENTER 2
ThomasBGill 20:e54792b89571 18 #define EXIT 3
ThomasBGill 20:e54792b89571 19 #define FLOOR_SEEN 4
ThomasBGill 20:e54792b89571 20 #define CHEST 5
ThomasBGill 20:e54792b89571 21 #define CHEST_OPENED 6
ThomasBGill 20:e54792b89571 22
ThomasBGill 20:e54792b89571 23 #define RIGHT 0
ThomasBGill 20:e54792b89571 24 #define LEFT 1
ThomasBGill 20:e54792b89571 25 #define UP 2
ThomasBGill 20:e54792b89571 26 #define DOWN 3
ThomasBGill 20:e54792b89571 27
ThomasBGill 22:dae750e4d749 28 #define MAP_WIDTH 84
ThomasBGill 22:dae750e4d749 29 #define MAP_HEIGHT 48
ThomasBGill 20:e54792b89571 30
ThomasBGill 35:2c290fa78f1d 31 /** Map Array
ThomasBGill 35:2c290fa78f1d 32 *
ThomasBGill 35:2c290fa78f1d 33 * @param map - Array which stores the map data for the game
ThomasBGill 35:2c290fa78f1d 34 *
ThomasBGill 35:2c290fa78f1d 35 */
ThomasBGill 22:dae750e4d749 36 extern int map[MAP_WIDTH][MAP_HEIGHT];
ThomasBGill 20:e54792b89571 37
ThomasBGill 20:e54792b89571 38 //Enterance coordinates
ThomasBGill 35:2c290fa78f1d 39 /** Enterance x co-ordinate
ThomasBGill 35:2c290fa78f1d 40 *
ThomasBGill 35:2c290fa78f1d 41 * @param enx - Variable which stores the x co-ordinate of the enterance of the current level
ThomasBGill 35:2c290fa78f1d 42 *
ThomasBGill 35:2c290fa78f1d 43 */
ThomasBGill 20:e54792b89571 44 extern int enx;
ThomasBGill 35:2c290fa78f1d 45
ThomasBGill 35:2c290fa78f1d 46 /** Enterance y co-ordinate
ThomasBGill 35:2c290fa78f1d 47 *
ThomasBGill 35:2c290fa78f1d 48 * @param eny - Variable which stores the y co-ordinate of the enterance of the current level
ThomasBGill 35:2c290fa78f1d 49 *
ThomasBGill 35:2c290fa78f1d 50 */
ThomasBGill 20:e54792b89571 51 extern int eny;
ThomasBGill 20:e54792b89571 52
ThomasBGill 20:e54792b89571 53 //Exit coordinates
ThomasBGill 35:2c290fa78f1d 54 /** Exit x co-ordinate
ThomasBGill 35:2c290fa78f1d 55 *
ThomasBGill 35:2c290fa78f1d 56 * @param exx - Variable which stores the x co-ordinate of the exit of the current level
ThomasBGill 35:2c290fa78f1d 57 *
ThomasBGill 35:2c290fa78f1d 58 */
ThomasBGill 20:e54792b89571 59 extern int exx;
ThomasBGill 35:2c290fa78f1d 60
ThomasBGill 35:2c290fa78f1d 61 /** Exit y co-ordinate
ThomasBGill 35:2c290fa78f1d 62 *
ThomasBGill 35:2c290fa78f1d 63 * @param exy- Variable which stores the y co-ordinate of the exit of the current level
ThomasBGill 35:2c290fa78f1d 64 *
ThomasBGill 35:2c290fa78f1d 65 */
ThomasBGill 20:e54792b89571 66 extern int exy;
ThomasBGill 20:e54792b89571 67
ThomasBGill 35:2c290fa78f1d 68 /** Start x co-ordinate
ThomasBGill 35:2c290fa78f1d 69 *
ThomasBGill 35:2c290fa78f1d 70 * @param sx - Variable which stores the x co-ordinate of the start of a room
ThomasBGill 35:2c290fa78f1d 71 *
ThomasBGill 35:2c290fa78f1d 72 */
ThomasBGill 20:e54792b89571 73 extern int sx;
ThomasBGill 35:2c290fa78f1d 74
ThomasBGill 35:2c290fa78f1d 75 /** Start y co-ordinate
ThomasBGill 35:2c290fa78f1d 76 *
ThomasBGill 35:2c290fa78f1d 77 * @param sy - Variable which stores the y co-ordinate of the start of a room
ThomasBGill 35:2c290fa78f1d 78 *
ThomasBGill 35:2c290fa78f1d 79 */
ThomasBGill 20:e54792b89571 80 extern int sy;
ThomasBGill 20:e54792b89571 81
ThomasBGill 35:2c290fa78f1d 82 /** Current Level
ThomasBGill 35:2c290fa78f1d 83 *
ThomasBGill 35:2c290fa78f1d 84 * @param level - Variable which stores the level number the player is currently on
ThomasBGill 35:2c290fa78f1d 85 *
ThomasBGill 35:2c290fa78f1d 86 */
ThomasBGill 20:e54792b89571 87 extern int level;
ThomasBGill 20:e54792b89571 88
ThomasBGill 35:2c290fa78f1d 89 /** Player x co-ordinate
ThomasBGill 35:2c290fa78f1d 90 *
ThomasBGill 35:2c290fa78f1d 91 * @param px - Variable which stores the current x co-ordinate of the player
ThomasBGill 35:2c290fa78f1d 92 *
ThomasBGill 35:2c290fa78f1d 93 */
ThomasBGill 21:aa4feee6aa39 94 extern int px;
ThomasBGill 35:2c290fa78f1d 95 /** Player y co-ordinate
ThomasBGill 35:2c290fa78f1d 96 *
ThomasBGill 35:2c290fa78f1d 97 * @param py - Variable which stores the current x co-ordinate of the player
ThomasBGill 35:2c290fa78f1d 98 *
ThomasBGill 35:2c290fa78f1d 99 */
ThomasBGill 21:aa4feee6aa39 100 extern int py;
ThomasBGill 21:aa4feee6aa39 101
ThomasBGill 35:2c290fa78f1d 102 /** Wall Fill
ThomasBGill 35:2c290fa78f1d 103 *
ThomasBGill 35:2c290fa78f1d 104 * Fills the map array with walls
ThomasBGill 35:2c290fa78f1d 105 *
ThomasBGill 35:2c290fa78f1d 106 */
ThomasBGill 20:e54792b89571 107 void Walls();
ThomasBGill 35:2c290fa78f1d 108
ThomasBGill 35:2c290fa78f1d 109 /** First room Creator
ThomasBGill 35:2c290fa78f1d 110 *
ThomasBGill 35:2c290fa78f1d 111 * Creates a room at a random position in the map with an enterance in it
ThomasBGill 35:2c290fa78f1d 112 *
ThomasBGill 35:2c290fa78f1d 113 */
ThomasBGill 20:e54792b89571 114 void FirstRoom();
ThomasBGill 35:2c290fa78f1d 115
ThomasBGill 35:2c290fa78f1d 116 /** Exit room Creator
ThomasBGill 35:2c290fa78f1d 117 *
ThomasBGill 35:2c290fa78f1d 118 * Creates a room at a random position in the map with an exit in it
ThomasBGill 35:2c290fa78f1d 119 *
ThomasBGill 35:2c290fa78f1d 120 */
ThomasBGill 20:e54792b89571 121 void ExitRoom();
ThomasBGill 35:2c290fa78f1d 122
ThomasBGill 35:2c290fa78f1d 123 /** Dungeon Room Creator
ThomasBGill 35:2c290fa78f1d 124 *
ThomasBGill 35:2c290fa78f1d 125 * Creates a room at a random position in the map with a chance of having a chest in it
ThomasBGill 35:2c290fa78f1d 126 *
ThomasBGill 35:2c290fa78f1d 127 */
ThomasBGill 20:e54792b89571 128 void DungeonRoomBuilder();
ThomasBGill 35:2c290fa78f1d 129
ThomasBGill 35:2c290fa78f1d 130 /** Neighbours
ThomasBGill 35:2c290fa78f1d 131 *
ThomasBGill 35:2c290fa78f1d 132 * Checks how many neighbouring cells at the current position are floors. It returns an integer value equal to the number of neighbours with floors.
ThomasBGill 35:2c290fa78f1d 133 * @param i - x co-ordinate of current position
ThomasBGill 35:2c290fa78f1d 134 * @param j - y co-ordinate of current position
ThomasBGill 35:2c290fa78f1d 135 *
ThomasBGill 35:2c290fa78f1d 136 */
ThomasBGill 20:e54792b89571 137 int Neighbours(int i, int j);
ThomasBGill 35:2c290fa78f1d 138
ThomasBGill 35:2c290fa78f1d 139 /** Dead Ends
ThomasBGill 35:2c290fa78f1d 140 *
ThomasBGill 35:2c290fa78f1d 141 * Deletes corridors that are dead ends
ThomasBGill 35:2c290fa78f1d 142 * @param d - How many times the function should iterate through the map
ThomasBGill 35:2c290fa78f1d 143 *
ThomasBGill 35:2c290fa78f1d 144 */
ThomasBGill 20:e54792b89571 145 void DeadEnds(int d);
ThomasBGill 35:2c290fa78f1d 146
ThomasBGill 35:2c290fa78f1d 147 /** Border
ThomasBGill 35:2c290fa78f1d 148 *
ThomasBGill 36:b64696135142 149 * Creates a 1 cell thick border of walls at the extremeties of the map
ThomasBGill 35:2c290fa78f1d 150 *
ThomasBGill 35:2c290fa78f1d 151 */
ThomasBGill 20:e54792b89571 152 void Border();
ThomasBGill 35:2c290fa78f1d 153
ThomasBGill 35:2c290fa78f1d 154 /** Random Floor Setter
ThomasBGill 35:2c290fa78f1d 155 *
ThomasBGill 35:2c290fa78f1d 156 * Randomly turns a wall in the map into a floor.
ThomasBGill 35:2c290fa78f1d 157 * @pararm r - How many times the function should be iterated
ThomasBGill 35:2c290fa78f1d 158 *
ThomasBGill 35:2c290fa78f1d 159 */
ThomasBGill 35:2c290fa78f1d 160 void RandFloor(int r)
ThomasBGill 35:2c290fa78f1d 161
ThomasBGill 35:2c290fa78f1d 162 /** Maze Kill
ThomasBGill 35:2c290fa78f1d 163 *
ThomasBGill 35:2c290fa78f1d 164 * The 'kill' phase of a hunt and kill maze algorithm.
ThomasBGill 35:2c290fa78f1d 165 * The algorithm walks in random directions (which do not conflict with previously made paths), turning walls into floors in the current direction until it hits a dead end
ThomasBGill 35:2c290fa78f1d 166 *
ThomasBGill 35:2c290fa78f1d 167 */
ThomasBGill 20:e54792b89571 168 void MazeKill();
ThomasBGill 35:2c290fa78f1d 169
ThomasBGill 35:2c290fa78f1d 170 /** Maze Maker
ThomasBGill 35:2c290fa78f1d 171 *
ThomasBGill 35:2c290fa78f1d 172 * Implements a 'hunt and kill' perfect maze algorithm
ThomasBGill 35:2c290fa78f1d 173 *
ThomasBGill 35:2c290fa78f1d 174 * (See http://www.astrolog.org/labyrnth/algrithm.htm for more information on the algorithm)
ThomasBGill 35:2c290fa78f1d 175 *
ThomasBGill 35:2c290fa78f1d 176 */
ThomasBGill 20:e54792b89571 177 void Maze();
ThomasBGill 35:2c290fa78f1d 178
ThomasBGill 35:2c290fa78f1d 179 /** Dungeon Builder
ThomasBGill 35:2c290fa78f1d 180 *
ThomasBGill 35:2c290fa78f1d 181 * Creates a 'dungeon' style level on the map array by generating a maze, adding enterance, exit and filler rooms, turning random tiles into floors and then removing the dead ends
ThomasBGill 35:2c290fa78f1d 182 *
ThomasBGill 35:2c290fa78f1d 183 */
ThomasBGill 20:e54792b89571 184 void DungeonBuilder();
ThomasBGill 35:2c290fa78f1d 185
ThomasBGill 35:2c290fa78f1d 186 /** Labyrinth Builder
ThomasBGill 35:2c290fa78f1d 187 *
ThomasBGill 35:2c290fa78f1d 188 * Creates a labyrinth level on the map array by generating a maze, adding enterance and exit rooms, turning random tiles into floors and then removing some of the dead ends
ThomasBGill 35:2c290fa78f1d 189 *
ThomasBGill 35:2c290fa78f1d 190 */
ThomasBGill 20:e54792b89571 191 void LabyrinthBuilder();
ThomasBGill 35:2c290fa78f1d 192
ThomasBGill 35:2c290fa78f1d 193 /** World Generator
ThomasBGill 35:2c290fa78f1d 194 *
ThomasBGill 35:2c290fa78f1d 195 * Clears the current map using the Walls() function and then generates a dungeon or labyrinth level
ThomasBGill 35:2c290fa78f1d 196 *
ThomasBGill 35:2c290fa78f1d 197 */
ThomasBGill 21:aa4feee6aa39 198 void World();
ThomasBGill 20:e54792b89571 199
ThomasBGill 20:e54792b89571 200 #endif