project for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
DCchico
Date:
Fri Oct 23 16:18:39 2020 -0400
Revision:
1:10330bce85cb
Child:
2:4947d6a82971
shell-code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 1:10330bce85cb 1 #include "graphics.h"
DCchico 1:10330bce85cb 2
DCchico 1:10330bce85cb 3 #include "globals.h"
DCchico 1:10330bce85cb 4
DCchico 1:10330bce85cb 5 void draw_nothing(int u, int v)
DCchico 1:10330bce85cb 6 {
DCchico 1:10330bce85cb 7 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
DCchico 1:10330bce85cb 8 }
DCchico 1:10330bce85cb 9
DCchico 1:10330bce85cb 10 void draw_img(int u, int v, const char* img)
DCchico 1:10330bce85cb 11 {
DCchico 1:10330bce85cb 12 int colors[11*11];
DCchico 1:10330bce85cb 13 for (int i = 0; i < 11*11; i++)
DCchico 1:10330bce85cb 14 {
DCchico 1:10330bce85cb 15 if (img[i] == 'R') colors[i] = RED;
DCchico 1:10330bce85cb 16 else if (img[i] == 'Y') colors[i] = 0xFFFF00; // Yellow
DCchico 1:10330bce85cb 17 else if (img[i] == 'G') colors[i] = GREEN;
DCchico 1:10330bce85cb 18 else if (img[i] == 'D') colors[i] = 0xD2691E; // "Dirt"
DCchico 1:10330bce85cb 19 else if (img[i] == '5') colors[i] = LGREY; // 50% grey
DCchico 1:10330bce85cb 20 else if (img[i] == '3') colors[i] = DGREY;
DCchico 1:10330bce85cb 21 else colors[i] = BLACK;
DCchico 1:10330bce85cb 22 }
DCchico 1:10330bce85cb 23 uLCD.BLIT(u, v, 11, 11, colors);
DCchico 1:10330bce85cb 24 wait_us(250); // Recovery time!
DCchico 1:10330bce85cb 25 }
DCchico 1:10330bce85cb 26
DCchico 1:10330bce85cb 27 void draw_wall(int u, int v)
DCchico 1:10330bce85cb 28 {
DCchico 1:10330bce85cb 29 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
DCchico 1:10330bce85cb 30 }
DCchico 1:10330bce85cb 31
DCchico 1:10330bce85cb 32 void draw_plant(int u, int v)
DCchico 1:10330bce85cb 33 {
DCchico 1:10330bce85cb 34 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 35 }
DCchico 1:10330bce85cb 36
DCchico 1:10330bce85cb 37 void draw_goodie(int u, int v)
DCchico 1:10330bce85cb 38 {
DCchico 1:10330bce85cb 39 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 40 }
DCchico 1:10330bce85cb 41
DCchico 1:10330bce85cb 42 void draw_snake_body(int u, int v)
DCchico 1:10330bce85cb 43 {
DCchico 1:10330bce85cb 44 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 45 }
DCchico 1:10330bce85cb 46
DCchico 1:10330bce85cb 47 void draw_snake_head(int u, int v)
DCchico 1:10330bce85cb 48 {
DCchico 1:10330bce85cb 49 //May need to design a snake head sprite
DCchico 1:10330bce85cb 50 //Tile still need to be designed on paper
DCchico 1:10330bce85cb 51
DCchico 1:10330bce85cb 52 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 53 }
DCchico 1:10330bce85cb 54
DCchico 1:10330bce85cb 55 void draw_snake_tail(int u, int v)
DCchico 1:10330bce85cb 56 {
DCchico 1:10330bce85cb 57 //May need to design a snake tail sprite
DCchico 1:10330bce85cb 58 //Tile still need to be designed on paper
DCchico 1:10330bce85cb 59 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 60 }
DCchico 1:10330bce85cb 61
DCchico 1:10330bce85cb 62