baseline features - a little buggy

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
robbiehuey
Date:
Sat Apr 10 02:08:02 2021 +0000
Revision:
2:cf4e61c051a4
Parent:
1:4421c1e849e9
hi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 0:95264f964374 1 #include "graphics.h"
DCchico 0:95264f964374 2 #include "globals.h"
DCchico 0:95264f964374 3
DCchico 0:95264f964374 4 #define YELLOW 0xFFFF00
DCchico 0:95264f964374 5 #define GREEN 0x00FF00
DCchico 0:95264f964374 6 #define WHITE 0xFFFFFF
DCchico 0:95264f964374 7 #define BLACK 0x000000
DCchico 0:95264f964374 8 #define BROWN 0xD2691E
DCchico 0:95264f964374 9 #define DIRT BROWN
DCchico 0:95264f964374 10 #define RED 0xFF0000
DCchico 0:95264f964374 11 #define ORANGE 0xFFA500
robbiehuey 1:4421c1e849e9 12
robbiehuey 1:4421c1e849e9 13 int SPRITE_ARR[]= {BLACK, BLACK, BLACK, BLACK, BLACK, BROWN, BROWN, GREEN, BLACK, BLACK, BLACK,
robbiehuey 1:4421c1e849e9 14 BLACK, BLACK, BLACK, BLACK, BLACK, BROWN, BLACK, BLACK, BLACK, BLACK, BLACK,
robbiehuey 1:4421c1e849e9 15 BLACK, BLACK, BLACK, RED, RED, RED, RED, RED, BLACK, BLACK, BLACK,
robbiehuey 1:4421c1e849e9 16 BLACK, BLACK, RED, RED, RED, RED, RED, RED, RED, BLACK, BLACK,
robbiehuey 1:4421c1e849e9 17 BLACK, RED, RED, RED, RED, RED, RED, RED, RED, RED, BLACK,
robbiehuey 1:4421c1e849e9 18 RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED,
robbiehuey 1:4421c1e849e9 19 RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED,
robbiehuey 1:4421c1e849e9 20 RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED,
robbiehuey 1:4421c1e849e9 21 BLACK, RED, RED, RED, RED, RED, RED, RED, RED, RED, BLACK,
robbiehuey 1:4421c1e849e9 22 BLACK, BLACK, RED, RED, RED, RED, RED, RED, RED, BLACK, BLACK,
robbiehuey 1:4421c1e849e9 23 BLACK, BLACK, BLACK, RED, RED, RED, RED, RED, BLACK, BLACK, BLACK};
robbiehuey 1:4421c1e849e9 24
robbiehuey 1:4421c1e849e9 25
DCchico 0:95264f964374 26 void draw_img(int u, int v, const char* img)
DCchico 0:95264f964374 27 {
DCchico 0:95264f964374 28 int colors[11*11];
DCchico 0:95264f964374 29 for (int i = 0; i < 11*11; i++)
DCchico 0:95264f964374 30 {
DCchico 0:95264f964374 31 if (img[i] == 'R') colors[i] = RED;
DCchico 0:95264f964374 32 else if (img[i] == 'Y') colors[i] = YELLOW;
DCchico 0:95264f964374 33 else if (img[i] == 'G') colors[i] = GREEN;
DCchico 0:95264f964374 34 else if (img[i] == 'D') colors[i] = DIRT;
robbiehuey 1:4421c1e849e9 35 else if (img[i] == '5') colors[i] = LGREY;
DCchico 0:95264f964374 36 // else if (img[i] == '3') colors[i] = DGREY;
DCchico 0:95264f964374 37 else colors[i] = BLACK;
DCchico 0:95264f964374 38 }
DCchico 0:95264f964374 39 uLCD.BLIT(u, v, 11, 11, colors);
DCchico 0:95264f964374 40 wait_us(250); // Recovery time!
DCchico 0:95264f964374 41 }
DCchico 0:95264f964374 42
DCchico 0:95264f964374 43 void draw_player(int u, int v, int key)
DCchico 0:95264f964374 44 {
DCchico 0:95264f964374 45 uLCD.filled_rectangle(u, v, u+11, v+11, WHITE);
DCchico 0:95264f964374 46 }
DCchico 0:95264f964374 47
DCchico 0:95264f964374 48 void draw_nothing(boundingBox b)
DCchico 0:95264f964374 49 {
DCchico 0:95264f964374 50 // Erase a bounding box
DCchico 0:95264f964374 51 uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, BLACK);
DCchico 0:95264f964374 52 }
DCchico 0:95264f964374 53
DCchico 0:95264f964374 54 void draw_bomb(boundingBox b)
DCchico 0:95264f964374 55 {
DCchico 0:95264f964374 56 // Draw an apple using a filled_rectangle or get creative and use a sprite!
DCchico 0:95264f964374 57 uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, RED);
DCchico 0:95264f964374 58 }
DCchico 0:95264f964374 59
DCchico 0:95264f964374 60 void draw_banana(boundingBox b)
DCchico 0:95264f964374 61 {
DCchico 0:95264f964374 62 // Draw a banana using a filled_rectangle or get creative and use a sprite!
DCchico 0:95264f964374 63 uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, YELLOW);
DCchico 0:95264f964374 64 }
DCchico 0:95264f964374 65
DCchico 0:95264f964374 66 void draw_orange(boundingBox b)
DCchico 0:95264f964374 67 {
DCchico 0:95264f964374 68 // Draw an orange using a filled_rectangle or get creative and use a sprite!
DCchico 0:95264f964374 69 uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, ORANGE);
DCchico 0:95264f964374 70 }
robbiehuey 1:4421c1e849e9 71
robbiehuey 1:4421c1e849e9 72 void draw_start() {
robbiehuey 1:4421c1e849e9 73 uLCD.BLIT(58,58,11,11,SPRITE_ARR);
robbiehuey 1:4421c1e849e9 74 wait_us(250);
robbiehuey 1:4421c1e849e9 75 }