Finished Lab 4 Pt 1
Dependencies: mbed Sounds PinDetect
DrawMaze.cpp@0:daf9e2f8e1a1, 2019-04-05 (annotated)
- Committer:
- trmontgomery
- Date:
- Fri Apr 05 19:46:26 2019 +0000
- Revision:
- 0:daf9e2f8e1a1
Finished Lab 4 pt 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
trmontgomery | 0:daf9e2f8e1a1 | 1 | #include "uLCD_4DGL.h" |
trmontgomery | 0:daf9e2f8e1a1 | 2 | #include "BuzzyGraphics.h" |
trmontgomery | 0:daf9e2f8e1a1 | 3 | #include "Buzzy.h" |
trmontgomery | 0:daf9e2f8e1a1 | 4 | |
trmontgomery | 0:daf9e2f8e1a1 | 5 | extern uLCD_4DGL guLCD; |
trmontgomery | 0:daf9e2f8e1a1 | 6 | extern char gDynaMaze[MAZE_NUM_ROW][MAZE_NUM_COL]; |
trmontgomery | 0:daf9e2f8e1a1 | 7 | extern Buzzy gBuzzy; |
trmontgomery | 0:daf9e2f8e1a1 | 8 | ///////////////////////////////////////////////////////////////////// |
trmontgomery | 0:daf9e2f8e1a1 | 9 | // The maze is a scaled down version of the LCD display |
trmontgomery | 0:daf9e2f8e1a1 | 10 | // Each element in the maze is really a 3x3 segment of the LCD |
trmontgomery | 0:daf9e2f8e1a1 | 11 | // This must be taken into account when drawing the maze on the LCD |
trmontgomery | 0:daf9e2f8e1a1 | 12 | |
trmontgomery | 0:daf9e2f8e1a1 | 13 | |
trmontgomery | 0:daf9e2f8e1a1 | 14 | // Draw a wall tile when |
trmontgomery | 0:daf9e2f8e1a1 | 15 | void DrawMazeWall(int const &x1, int const &y1) |
trmontgomery | 0:daf9e2f8e1a1 | 16 | { |
trmontgomery | 0:daf9e2f8e1a1 | 17 | int ii = 3*x1+1; |
trmontgomery | 0:daf9e2f8e1a1 | 18 | int jj = 3*y1+1; |
trmontgomery | 0:daf9e2f8e1a1 | 19 | guLCD.filled_rectangle(ii-1, jj-1, ii+1, jj+1, _BLUE); |
trmontgomery | 0:daf9e2f8e1a1 | 20 | } |
trmontgomery | 0:daf9e2f8e1a1 | 21 | /* |
trmontgomery | 0:daf9e2f8e1a1 | 22 | ////////////////////////////////////////////////////////////////////// |
trmontgomery | 0:daf9e2f8e1a1 | 23 | Use the following #defines to determine which icon to draw in the LCD |
trmontgomery | 0:daf9e2f8e1a1 | 24 | #define BLUE_SQUARE 1 |
trmontgomery | 0:daf9e2f8e1a1 | 25 | #define HONEYDROP_SQUARE 2 |
trmontgomery | 0:daf9e2f8e1a1 | 26 | #define PWRUP_SQUARE 3 |
trmontgomery | 0:daf9e2f8e1a1 | 27 | #define GHOST_ICON 4 |
trmontgomery | 0:daf9e2f8e1a1 | 28 | #define BUZZY_ICON 5 |
trmontgomery | 0:daf9e2f8e1a1 | 29 | #define TRAP_LINE 6 |
trmontgomery | 0:daf9e2f8e1a1 | 30 | |
trmontgomery | 0:daf9e2f8e1a1 | 31 | When drawing the ghosts draw one of each color |
trmontgomery | 0:daf9e2f8e1a1 | 32 | */ |
trmontgomery | 0:daf9e2f8e1a1 | 33 | void DrawMaze() |
trmontgomery | 0:daf9e2f8e1a1 | 34 | { |
trmontgomery | 0:daf9e2f8e1a1 | 35 | |
trmontgomery | 0:daf9e2f8e1a1 | 36 | for (int ii = 0 ; ii < MAZE_NUM_ROW ; ii++) |
trmontgomery | 0:daf9e2f8e1a1 | 37 | { |
trmontgomery | 0:daf9e2f8e1a1 | 38 | for (int jj = 0 ; jj < MAZE_NUM_COL ; jj++) |
trmontgomery | 0:daf9e2f8e1a1 | 39 | { |
trmontgomery | 0:daf9e2f8e1a1 | 40 | if (gDynaMaze[ii][jj] == HONEYDROP_SQUARE){ |
trmontgomery | 0:daf9e2f8e1a1 | 41 | guLCD.BLIT(ii*3, jj*3, 3, 3, &HoneyDropIcon[0][0]); |
trmontgomery | 0:daf9e2f8e1a1 | 42 | } else if (gDynaMaze[ii][jj] == BLUE_SQUARE){ |
trmontgomery | 0:daf9e2f8e1a1 | 43 | DrawMazeWall(ii, jj); |
trmontgomery | 0:daf9e2f8e1a1 | 44 | } else if (gDynaMaze[ii][jj] == PWRUP_SQUARE){ |
trmontgomery | 0:daf9e2f8e1a1 | 45 | guLCD.BLIT((ii*3+1)-4, (jj*3+1)-4, 9, 9, &PowerUpIcon[0][0]); |
trmontgomery | 0:daf9e2f8e1a1 | 46 | } else if (gDynaMaze[ii][jj] == GHOST_ICON){ |
trmontgomery | 0:daf9e2f8e1a1 | 47 | guLCD.BLIT((ii*3)-4, (jj*3)-4, 9, 9, &VioletGhost[0][0][0]); |
trmontgomery | 0:daf9e2f8e1a1 | 48 | } else if (gDynaMaze[ii][jj] == BUZZY_ICON){ |
trmontgomery | 0:daf9e2f8e1a1 | 49 | guLCD.BLIT((3*ii+1)-4, (3*jj+1)-4, 9, 9, &BuzzyIcon[0][0][0]); |
trmontgomery | 0:daf9e2f8e1a1 | 50 | gBuzzy.SetLocation(ii,jj); |
trmontgomery | 0:daf9e2f8e1a1 | 51 | } |
trmontgomery | 0:daf9e2f8e1a1 | 52 | } |
trmontgomery | 0:daf9e2f8e1a1 | 53 | } |
trmontgomery | 0:daf9e2f8e1a1 | 54 | } |