Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PowerControl mbed
main.cpp@7:cd799c701997, 2015-04-17 (annotated)
- Committer:
- ThomasBGill
- Date:
- Fri Apr 17 12:58:04 2015 +0000
- Revision:
- 7:cd799c701997
- Parent:
- 6:ca5db4353c95
- Child:
- 8:ee857f0147aa
Start of player 'camera'
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThomasBGill | 0:9200b3c387ed | 1 | #include "mbed.h" |
ThomasBGill | 0:9200b3c387ed | 2 | #include "N5110.h" |
ThomasBGill | 1:0f774d41584c | 3 | #include "PowerControl/PowerControl.h" |
ThomasBGill | 1:0f774d41584c | 4 | #include "PowerControl/EthernetPowerControl.h" |
ThomasBGill | 0:9200b3c387ed | 5 | |
ThomasBGill | 0:9200b3c387ed | 6 | // vcc sce rst dc mosi clk led |
ThomasBGill | 0:9200b3c387ed | 7 | N5110 lcd (p5, p6, p7, p8, p11, p13, p21); |
ThomasBGill | 0:9200b3c387ed | 8 | InterruptIn Act (p22); |
ThomasBGill | 0:9200b3c387ed | 9 | InterruptIn Start (p23); |
ThomasBGill | 0:9200b3c387ed | 10 | InterruptIn Up (p24); |
ThomasBGill | 0:9200b3c387ed | 11 | InterruptIn Down (p25); |
ThomasBGill | 0:9200b3c387ed | 12 | InterruptIn Left (p26); |
ThomasBGill | 0:9200b3c387ed | 13 | InterruptIn Right (p27); |
ThomasBGill | 0:9200b3c387ed | 14 | AnalogIn Noise (p19); |
ThomasBGill | 0:9200b3c387ed | 15 | |
ThomasBGill | 1:0f774d41584c | 16 | #define USR_POWERDOWN (0x104) |
ThomasBGill | 1:0f774d41584c | 17 | |
ThomasBGill | 0:9200b3c387ed | 18 | #define WALL 0 |
ThomasBGill | 0:9200b3c387ed | 19 | #define FLOOR 1 |
ThomasBGill | 0:9200b3c387ed | 20 | #define ENTER 2 |
ThomasBGill | 0:9200b3c387ed | 21 | #define EXIT 3 |
ThomasBGill | 0:9200b3c387ed | 22 | |
ThomasBGill | 0:9200b3c387ed | 23 | #define RIGHT 0 |
ThomasBGill | 0:9200b3c387ed | 24 | #define LEFT 1 |
ThomasBGill | 0:9200b3c387ed | 25 | #define UP 2 |
ThomasBGill | 0:9200b3c387ed | 26 | #define DOWN 3 |
ThomasBGill | 0:9200b3c387ed | 27 | |
ThomasBGill | 3:1a25939df22a | 28 | #define SOUTH 0 |
ThomasBGill | 3:1a25939df22a | 29 | #define EAST 1 |
ThomasBGill | 3:1a25939df22a | 30 | |
ThomasBGill | 7:cd799c701997 | 31 | struct TILE |
ThomasBGill | 7:cd799c701997 | 32 | { |
ThomasBGill | 7:cd799c701997 | 33 | char Symbol; // Symbol for this tile |
ThomasBGill | 7:cd799c701997 | 34 | bool Passable; // Can tile be walked on |
ThomasBGill | 7:cd799c701997 | 35 | }; |
ThomasBGill | 7:cd799c701997 | 36 | |
ThomasBGill | 7:cd799c701997 | 37 | TILE TileList[] = { |
ThomasBGill | 7:cd799c701997 | 38 | { '#', false }, // 0- WALL |
ThomasBGill | 7:cd799c701997 | 39 | { '.', true}, // 1- FLOOR |
ThomasBGill | 7:cd799c701997 | 40 | { '+', true }, // 2- ENTER |
ThomasBGill | 7:cd799c701997 | 41 | { 'x', true }, // 3- EXIT |
ThomasBGill | 7:cd799c701997 | 42 | }; |
ThomasBGill | 7:cd799c701997 | 43 | |
ThomasBGill | 7:cd799c701997 | 44 | |
ThomasBGill | 0:9200b3c387ed | 45 | //Variables |
ThomasBGill | 0:9200b3c387ed | 46 | int buttonFlagA = 0; |
ThomasBGill | 0:9200b3c387ed | 47 | int buttonFlagS = 0; |
ThomasBGill | 0:9200b3c387ed | 48 | int buttonFlagU = 0; |
ThomasBGill | 0:9200b3c387ed | 49 | int buttonFlagD = 0; |
ThomasBGill | 0:9200b3c387ed | 50 | int buttonFlagL = 0; |
ThomasBGill | 0:9200b3c387ed | 51 | int buttonFlagR = 0; |
ThomasBGill | 0:9200b3c387ed | 52 | |
ThomasBGill | 0:9200b3c387ed | 53 | int map[84][48]; |
ThomasBGill | 0:9200b3c387ed | 54 | |
ThomasBGill | 2:0b0311609edc | 55 | //Enterance coordinates |
ThomasBGill | 2:0b0311609edc | 56 | int enx; |
ThomasBGill | 2:0b0311609edc | 57 | int eny; |
ThomasBGill | 2:0b0311609edc | 58 | |
ThomasBGill | 2:0b0311609edc | 59 | //Exit coordinates |
ThomasBGill | 2:0b0311609edc | 60 | int exx; |
ThomasBGill | 2:0b0311609edc | 61 | int exy; |
ThomasBGill | 2:0b0311609edc | 62 | |
ThomasBGill | 1:0f774d41584c | 63 | int sx; |
ThomasBGill | 1:0f774d41584c | 64 | int sy; |
ThomasBGill | 1:0f774d41584c | 65 | int dir; |
ThomasBGill | 1:0f774d41584c | 66 | |
ThomasBGill | 2:0b0311609edc | 67 | int n; |
ThomasBGill | 2:0b0311609edc | 68 | |
ThomasBGill | 7:cd799c701997 | 69 | //Space type player is on |
ThomasBGill | 7:cd799c701997 | 70 | int pSpace; |
ThomasBGill | 7:cd799c701997 | 71 | |
ThomasBGill | 7:cd799c701997 | 72 | //Player coordinates |
ThomasBGill | 7:cd799c701997 | 73 | int px; |
ThomasBGill | 7:cd799c701997 | 74 | int py; |
ThomasBGill | 2:0b0311609edc | 75 | |
ThomasBGill | 1:0f774d41584c | 76 | //Power Saving |
ThomasBGill | 1:0f774d41584c | 77 | int semihost_powerdown() |
ThomasBGill | 1:0f774d41584c | 78 | { |
ThomasBGill | 1:0f774d41584c | 79 | uint32_t arg; |
ThomasBGill | 1:0f774d41584c | 80 | return __semihost(USR_POWERDOWN, &arg); |
ThomasBGill | 1:0f774d41584c | 81 | } |
ThomasBGill | 1:0f774d41584c | 82 | |
ThomasBGill | 0:9200b3c387ed | 83 | //ISR |
ThomasBGill | 0:9200b3c387ed | 84 | void ActPressed() |
ThomasBGill | 0:9200b3c387ed | 85 | { |
ThomasBGill | 0:9200b3c387ed | 86 | buttonFlagA = 0; |
ThomasBGill | 0:9200b3c387ed | 87 | } |
ThomasBGill | 0:9200b3c387ed | 88 | void StartPressed() |
ThomasBGill | 0:9200b3c387ed | 89 | { |
ThomasBGill | 0:9200b3c387ed | 90 | buttonFlagS = 0; |
ThomasBGill | 0:9200b3c387ed | 91 | } |
ThomasBGill | 0:9200b3c387ed | 92 | void UpPressed() |
ThomasBGill | 0:9200b3c387ed | 93 | { |
ThomasBGill | 0:9200b3c387ed | 94 | buttonFlagU = 0; |
ThomasBGill | 0:9200b3c387ed | 95 | } |
ThomasBGill | 0:9200b3c387ed | 96 | void DownPressed() |
ThomasBGill | 0:9200b3c387ed | 97 | { |
ThomasBGill | 0:9200b3c387ed | 98 | buttonFlagD = 0; |
ThomasBGill | 0:9200b3c387ed | 99 | } |
ThomasBGill | 0:9200b3c387ed | 100 | void LeftPressed() |
ThomasBGill | 0:9200b3c387ed | 101 | { |
ThomasBGill | 0:9200b3c387ed | 102 | buttonFlagL = 0; |
ThomasBGill | 0:9200b3c387ed | 103 | } |
ThomasBGill | 0:9200b3c387ed | 104 | void RightPressed() |
ThomasBGill | 0:9200b3c387ed | 105 | { |
ThomasBGill | 0:9200b3c387ed | 106 | buttonFlagR = 0; |
ThomasBGill | 0:9200b3c387ed | 107 | } |
ThomasBGill | 0:9200b3c387ed | 108 | |
ThomasBGill | 0:9200b3c387ed | 109 | void Walls() |
ThomasBGill | 0:9200b3c387ed | 110 | { |
ThomasBGill | 0:9200b3c387ed | 111 | //Fill map with walls |
ThomasBGill | 0:9200b3c387ed | 112 | for(int i=0; i<84; i++) { |
ThomasBGill | 0:9200b3c387ed | 113 | for (int j=0; j<48; j++) { |
ThomasBGill | 3:1a25939df22a | 114 | |
ThomasBGill | 0:9200b3c387ed | 115 | map[i][j] = WALL; |
ThomasBGill | 0:9200b3c387ed | 116 | } |
ThomasBGill | 0:9200b3c387ed | 117 | } |
ThomasBGill | 0:9200b3c387ed | 118 | } |
ThomasBGill | 0:9200b3c387ed | 119 | |
ThomasBGill | 3:1a25939df22a | 120 | void Floors() |
ThomasBGill | 3:1a25939df22a | 121 | { |
ThomasBGill | 3:1a25939df22a | 122 | //Fill map with floors |
ThomasBGill | 3:1a25939df22a | 123 | for(int i=0; i<84; i++) { |
ThomasBGill | 3:1a25939df22a | 124 | for (int j=0; j<48; j++) { |
ThomasBGill | 3:1a25939df22a | 125 | map[i][j] = FLOOR; |
ThomasBGill | 3:1a25939df22a | 126 | } |
ThomasBGill | 3:1a25939df22a | 127 | } |
ThomasBGill | 3:1a25939df22a | 128 | } |
ThomasBGill | 3:1a25939df22a | 129 | |
ThomasBGill | 1:0f774d41584c | 130 | void DrawMap() |
ThomasBGill | 1:0f774d41584c | 131 | { |
ThomasBGill | 1:0f774d41584c | 132 | //Draw map on screen |
ThomasBGill | 1:0f774d41584c | 133 | for(int i=0; i<84; i++) { |
ThomasBGill | 1:0f774d41584c | 134 | for (int j=0; j<48; j++) { |
ThomasBGill | 1:0f774d41584c | 135 | if(map[i][j] == FLOOR) { |
ThomasBGill | 1:0f774d41584c | 136 | lcd.clearPixel(i, j); |
ThomasBGill | 1:0f774d41584c | 137 | } else { |
ThomasBGill | 1:0f774d41584c | 138 | lcd.setPixel(i, j); |
ThomasBGill | 1:0f774d41584c | 139 | } |
ThomasBGill | 1:0f774d41584c | 140 | } |
ThomasBGill | 1:0f774d41584c | 141 | } |
ThomasBGill | 1:0f774d41584c | 142 | lcd.refresh(); |
ThomasBGill | 1:0f774d41584c | 143 | } |
ThomasBGill | 1:0f774d41584c | 144 | |
ThomasBGill | 0:9200b3c387ed | 145 | void FirstRoom() |
ThomasBGill | 0:9200b3c387ed | 146 | { |
ThomasBGill | 0:9200b3c387ed | 147 | //Create initial room |
ThomasBGill | 1:0f774d41584c | 148 | int si = rand()%25 + 1; |
ThomasBGill | 1:0f774d41584c | 149 | int sj = rand()%15 + 1; |
ThomasBGill | 0:9200b3c387ed | 150 | |
ThomasBGill | 0:9200b3c387ed | 151 | int sw = rand()%5+5; |
ThomasBGill | 0:9200b3c387ed | 152 | int sh = rand()%5+5; |
ThomasBGill | 0:9200b3c387ed | 153 | |
ThomasBGill | 0:9200b3c387ed | 154 | for(int i = si, w = si + sw; i <w; i++) { |
ThomasBGill | 0:9200b3c387ed | 155 | for (int j = sj, h = sj + sh; j <h; j++) { |
ThomasBGill | 0:9200b3c387ed | 156 | map[i][j] = FLOOR; |
ThomasBGill | 0:9200b3c387ed | 157 | } |
ThomasBGill | 0:9200b3c387ed | 158 | } |
ThomasBGill | 0:9200b3c387ed | 159 | //Create enterance in room |
ThomasBGill | 2:0b0311609edc | 160 | enx = rand()%sw + si; |
ThomasBGill | 2:0b0311609edc | 161 | eny = rand()%sh + sj; |
ThomasBGill | 2:0b0311609edc | 162 | map[enx][eny] = ENTER; |
ThomasBGill | 2:0b0311609edc | 163 | } |
ThomasBGill | 2:0b0311609edc | 164 | |
ThomasBGill | 5:9bd276652111 | 165 | void ExitRoom() |
ThomasBGill | 5:9bd276652111 | 166 | { |
ThomasBGill | 6:ca5db4353c95 | 167 | //Create exit room |
ThomasBGill | 5:9bd276652111 | 168 | int si = rand()%50 + 30; |
ThomasBGill | 5:9bd276652111 | 169 | int sj = rand()%25 + 20; |
ThomasBGill | 5:9bd276652111 | 170 | |
ThomasBGill | 5:9bd276652111 | 171 | int sw = rand()%5+5; |
ThomasBGill | 5:9bd276652111 | 172 | int sh = rand()%5+5; |
ThomasBGill | 5:9bd276652111 | 173 | |
ThomasBGill | 5:9bd276652111 | 174 | for(int i = si, w = si + sw; i <w; i++) { |
ThomasBGill | 5:9bd276652111 | 175 | for (int j = sj, h = sj + sh; j <h; j++) { |
ThomasBGill | 5:9bd276652111 | 176 | map[i][j] = FLOOR; |
ThomasBGill | 5:9bd276652111 | 177 | } |
ThomasBGill | 5:9bd276652111 | 178 | } |
ThomasBGill | 6:ca5db4353c95 | 179 | //Create exit in room |
ThomasBGill | 5:9bd276652111 | 180 | enx = rand()%sw + si; |
ThomasBGill | 5:9bd276652111 | 181 | eny = rand()%sh + sj; |
ThomasBGill | 5:9bd276652111 | 182 | map[enx][eny] = EXIT; |
ThomasBGill | 5:9bd276652111 | 183 | } |
ThomasBGill | 5:9bd276652111 | 184 | |
ThomasBGill | 2:0b0311609edc | 185 | void DungeonRoomBuilder() |
ThomasBGill | 2:0b0311609edc | 186 | { |
ThomasBGill | 2:0b0311609edc | 187 | sx = rand()%84; |
ThomasBGill | 2:0b0311609edc | 188 | sy = rand()%48; |
ThomasBGill | 2:0b0311609edc | 189 | |
ThomasBGill | 2:0b0311609edc | 190 | //Get length |
ThomasBGill | 2:0b0311609edc | 191 | int sw = rand()%5 + 5; |
ThomasBGill | 2:0b0311609edc | 192 | int sh = rand()%5 + 5; |
ThomasBGill | 2:0b0311609edc | 193 | |
ThomasBGill | 2:0b0311609edc | 194 | int b = 0; |
ThomasBGill | 2:0b0311609edc | 195 | |
ThomasBGill | 2:0b0311609edc | 196 | //Check each space. +1 to variable if wall. If total = w*h then build room |
ThomasBGill | 2:0b0311609edc | 197 | for(int i = sx; i < sx + sw; i++) { |
ThomasBGill | 2:0b0311609edc | 198 | for(int j = sy; j < sy + sh; j++) { |
ThomasBGill | 2:0b0311609edc | 199 | if(map[i][j] == WALL) { |
ThomasBGill | 2:0b0311609edc | 200 | b++; |
ThomasBGill | 2:0b0311609edc | 201 | } |
ThomasBGill | 2:0b0311609edc | 202 | } |
ThomasBGill | 2:0b0311609edc | 203 | } |
ThomasBGill | 2:0b0311609edc | 204 | if(b == sw*sh) { |
ThomasBGill | 2:0b0311609edc | 205 | for(int i = sx; i < sx + sw; i++) { |
ThomasBGill | 2:0b0311609edc | 206 | for(int j = sy; j < sy + sh; j++) { |
ThomasBGill | 2:0b0311609edc | 207 | if(i < 84 && j < 48) { |
ThomasBGill | 1:0f774d41584c | 208 | map[i][j] = FLOOR; |
ThomasBGill | 1:0f774d41584c | 209 | } |
ThomasBGill | 1:0f774d41584c | 210 | } |
ThomasBGill | 1:0f774d41584c | 211 | } |
ThomasBGill | 1:0f774d41584c | 212 | } |
ThomasBGill | 1:0f774d41584c | 213 | } |
ThomasBGill | 1:0f774d41584c | 214 | |
ThomasBGill | 4:6482ceb08dc8 | 215 | void Neighbours() |
ThomasBGill | 4:6482ceb08dc8 | 216 | { |
ThomasBGill | 4:6482ceb08dc8 | 217 | |
ThomasBGill | 4:6482ceb08dc8 | 218 | //Check neighbours |
ThomasBGill | 4:6482ceb08dc8 | 219 | n = 0; |
ThomasBGill | 4:6482ceb08dc8 | 220 | |
ThomasBGill | 4:6482ceb08dc8 | 221 | if(map[sx+1][sy] == FLOOR) { |
ThomasBGill | 4:6482ceb08dc8 | 222 | n++; |
ThomasBGill | 4:6482ceb08dc8 | 223 | } |
ThomasBGill | 4:6482ceb08dc8 | 224 | if(map[sx-1][sy] == FLOOR) { |
ThomasBGill | 4:6482ceb08dc8 | 225 | n++; |
ThomasBGill | 4:6482ceb08dc8 | 226 | } |
ThomasBGill | 4:6482ceb08dc8 | 227 | if(map[sx][sy+1] == FLOOR) { |
ThomasBGill | 4:6482ceb08dc8 | 228 | n++; |
ThomasBGill | 4:6482ceb08dc8 | 229 | } |
ThomasBGill | 4:6482ceb08dc8 | 230 | if(map[sx][sy-1] == FLOOR) { |
ThomasBGill | 4:6482ceb08dc8 | 231 | n++; |
ThomasBGill | 4:6482ceb08dc8 | 232 | } |
ThomasBGill | 4:6482ceb08dc8 | 233 | } |
ThomasBGill | 4:6482ceb08dc8 | 234 | |
ThomasBGill | 4:6482ceb08dc8 | 235 | void DeadEnds() |
ThomasBGill | 4:6482ceb08dc8 | 236 | { |
ThomasBGill | 5:9bd276652111 | 237 | for (int del = 20; del > 0; del--) { |
ThomasBGill | 4:6482ceb08dc8 | 238 | for(int i = 0; i < 84; i++) { |
ThomasBGill | 4:6482ceb08dc8 | 239 | for(int j = 0; j < 48; j++) { |
ThomasBGill | 4:6482ceb08dc8 | 240 | |
ThomasBGill | 4:6482ceb08dc8 | 241 | sx = i; |
ThomasBGill | 4:6482ceb08dc8 | 242 | sy = j; |
ThomasBGill | 4:6482ceb08dc8 | 243 | |
ThomasBGill | 4:6482ceb08dc8 | 244 | Neighbours(); |
ThomasBGill | 4:6482ceb08dc8 | 245 | |
ThomasBGill | 7:cd799c701997 | 246 | if(n < 2) { |
ThomasBGill | 4:6482ceb08dc8 | 247 | map[i][j] = WALL; |
ThomasBGill | 4:6482ceb08dc8 | 248 | } |
ThomasBGill | 4:6482ceb08dc8 | 249 | } |
ThomasBGill | 4:6482ceb08dc8 | 250 | } |
ThomasBGill | 4:6482ceb08dc8 | 251 | } |
ThomasBGill | 4:6482ceb08dc8 | 252 | } |
ThomasBGill | 4:6482ceb08dc8 | 253 | |
ThomasBGill | 5:9bd276652111 | 254 | void Border() |
ThomasBGill | 5:9bd276652111 | 255 | { |
ThomasBGill | 5:9bd276652111 | 256 | |
ThomasBGill | 5:9bd276652111 | 257 | for(int i = 0; i < 84; i++) { |
ThomasBGill | 5:9bd276652111 | 258 | for(int j = 0; j < 48; j++) { |
ThomasBGill | 5:9bd276652111 | 259 | |
ThomasBGill | 5:9bd276652111 | 260 | if(i == 0 || i == 83 || j == 0 || j == 47) { |
ThomasBGill | 5:9bd276652111 | 261 | |
ThomasBGill | 5:9bd276652111 | 262 | map[i][j] = WALL; |
ThomasBGill | 5:9bd276652111 | 263 | |
ThomasBGill | 5:9bd276652111 | 264 | } |
ThomasBGill | 5:9bd276652111 | 265 | } |
ThomasBGill | 5:9bd276652111 | 266 | } |
ThomasBGill | 5:9bd276652111 | 267 | } |
ThomasBGill | 4:6482ceb08dc8 | 268 | |
ThomasBGill | 2:0b0311609edc | 269 | void Maze() |
ThomasBGill | 2:0b0311609edc | 270 | { |
ThomasBGill | 3:1a25939df22a | 271 | for(int i = 0; i < 84; i+=2) { |
ThomasBGill | 3:1a25939df22a | 272 | for(int j = 0; j < 48; j+=2) { |
ThomasBGill | 2:0b0311609edc | 273 | |
ThomasBGill | 5:9bd276652111 | 274 | if(map[i][j] == WALL) { |
ThomasBGill | 5:9bd276652111 | 275 | map[i][j] = FLOOR; |
ThomasBGill | 5:9bd276652111 | 276 | } |
ThomasBGill | 2:0b0311609edc | 277 | |
ThomasBGill | 3:1a25939df22a | 278 | dir = rand()%2; //South or east |
ThomasBGill | 2:0b0311609edc | 279 | |
ThomasBGill | 4:6482ceb08dc8 | 280 | |
ThomasBGill | 5:9bd276652111 | 281 | if(dir == SOUTH && j < 47 && map[i][j+1] == WALL) { |
ThomasBGill | 3:1a25939df22a | 282 | map[i][j+1] = FLOOR; |
ThomasBGill | 2:0b0311609edc | 283 | } |
ThomasBGill | 5:9bd276652111 | 284 | if(dir == EAST && i < 84 && map[i+1][j] == WALL) { |
ThomasBGill | 3:1a25939df22a | 285 | map[i+1][j] = FLOOR; |
ThomasBGill | 2:0b0311609edc | 286 | } |
ThomasBGill | 2:0b0311609edc | 287 | } |
ThomasBGill | 2:0b0311609edc | 288 | } |
ThomasBGill | 3:1a25939df22a | 289 | |
ThomasBGill | 4:6482ceb08dc8 | 290 | for(int space = rand()%50 + 51; space > 0; space--) { |
ThomasBGill | 3:1a25939df22a | 291 | |
ThomasBGill | 3:1a25939df22a | 292 | int i = rand()% 84; |
ThomasBGill | 3:1a25939df22a | 293 | int j = rand()% 48; |
ThomasBGill | 3:1a25939df22a | 294 | |
ThomasBGill | 5:9bd276652111 | 295 | if(rand()%2 == 0 && map[i][j] == WALL) { |
ThomasBGill | 3:1a25939df22a | 296 | map[i][j] = FLOOR; |
ThomasBGill | 3:1a25939df22a | 297 | } |
ThomasBGill | 3:1a25939df22a | 298 | } |
ThomasBGill | 4:6482ceb08dc8 | 299 | |
ThomasBGill | 5:9bd276652111 | 300 | Border(); |
ThomasBGill | 5:9bd276652111 | 301 | |
ThomasBGill | 4:6482ceb08dc8 | 302 | DeadEnds(); |
ThomasBGill | 3:1a25939df22a | 303 | |
ThomasBGill | 2:0b0311609edc | 304 | } |
ThomasBGill | 2:0b0311609edc | 305 | |
ThomasBGill | 2:0b0311609edc | 306 | void DungeonBuilder() |
ThomasBGill | 0:9200b3c387ed | 307 | { |
ThomasBGill | 1:0f774d41584c | 308 | |
ThomasBGill | 4:6482ceb08dc8 | 309 | FirstRoom(); |
ThomasBGill | 5:9bd276652111 | 310 | ExitRoom(); |
ThomasBGill | 4:6482ceb08dc8 | 311 | |
ThomasBGill | 2:0b0311609edc | 312 | int rn = rand()%20 + 20; |
ThomasBGill | 2:0b0311609edc | 313 | |
ThomasBGill | 2:0b0311609edc | 314 | for(int i = rn; i>0; i--) { |
ThomasBGill | 2:0b0311609edc | 315 | DungeonRoomBuilder(); |
ThomasBGill | 2:0b0311609edc | 316 | } |
ThomasBGill | 2:0b0311609edc | 317 | |
ThomasBGill | 5:9bd276652111 | 318 | |
ThomasBGill | 4:6482ceb08dc8 | 319 | |
ThomasBGill | 3:1a25939df22a | 320 | DrawMap(); |
ThomasBGill | 4:6482ceb08dc8 | 321 | wait(2.0); |
ThomasBGill | 2:0b0311609edc | 322 | |
ThomasBGill | 3:1a25939df22a | 323 | Maze(); |
ThomasBGill | 3:1a25939df22a | 324 | |
ThomasBGill | 2:0b0311609edc | 325 | } |
ThomasBGill | 2:0b0311609edc | 326 | |
ThomasBGill | 2:0b0311609edc | 327 | void World() |
ThomasBGill | 2:0b0311609edc | 328 | { |
ThomasBGill | 2:0b0311609edc | 329 | Walls(); |
ThomasBGill | 6:ca5db4353c95 | 330 | |
ThomasBGill | 3:1a25939df22a | 331 | DungeonBuilder(); |
ThomasBGill | 6:ca5db4353c95 | 332 | |
ThomasBGill | 0:9200b3c387ed | 333 | DrawMap(); |
ThomasBGill | 1:0f774d41584c | 334 | |
ThomasBGill | 0:9200b3c387ed | 335 | } |
ThomasBGill | 0:9200b3c387ed | 336 | |
ThomasBGill | 0:9200b3c387ed | 337 | int main() |
ThomasBGill | 0:9200b3c387ed | 338 | { |
ThomasBGill | 1:0f774d41584c | 339 | //Power Saving |
ThomasBGill | 1:0f774d41584c | 340 | PHY_PowerDown (); |
ThomasBGill | 1:0f774d41584c | 341 | int result = semihost_powerdown(); |
ThomasBGill | 1:0f774d41584c | 342 | |
ThomasBGill | 1:0f774d41584c | 343 | //Generate random seed |
ThomasBGill | 0:9200b3c387ed | 344 | srand(Noise*1000000); |
ThomasBGill | 1:0f774d41584c | 345 | |
ThomasBGill | 1:0f774d41584c | 346 | //Initilize screen |
ThomasBGill | 0:9200b3c387ed | 347 | lcd.init(); |
ThomasBGill | 7:cd799c701997 | 348 | |
ThomasBGill | 7:cd799c701997 | 349 | World(); |
ThomasBGill | 0:9200b3c387ed | 350 | |
ThomasBGill | 1:0f774d41584c | 351 | //Game loop |
ThomasBGill | 0:9200b3c387ed | 352 | while(1) { |
ThomasBGill | 7:cd799c701997 | 353 | |
ThomasBGill | 0:9200b3c387ed | 354 | } |
ThomasBGill | 0:9200b3c387ed | 355 | } |