Snake
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: graphics.cpp
- Revision:
- 1:10330bce85cb
- Child:
- 2:4947d6a82971
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphics.cpp Fri Oct 23 16:18:39 2020 -0400 @@ -0,0 +1,62 @@ +#include "graphics.h" + +#include "globals.h" + +void draw_nothing(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, BLACK); +} + +void draw_img(int u, int v, const char* img) +{ + int colors[11*11]; + for (int i = 0; i < 11*11; i++) + { + if (img[i] == 'R') colors[i] = RED; + else if (img[i] == 'Y') colors[i] = 0xFFFF00; // Yellow + else if (img[i] == 'G') colors[i] = GREEN; + else if (img[i] == 'D') colors[i] = 0xD2691E; // "Dirt" + else if (img[i] == '5') colors[i] = LGREY; // 50% grey + else if (img[i] == '3') colors[i] = DGREY; + else colors[i] = BLACK; + } + uLCD.BLIT(u, v, 11, 11, colors); + wait_us(250); // Recovery time! +} + +void draw_wall(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, BLACK); +} + +void draw_plant(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); +} + +void draw_goodie(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); +} + +void draw_snake_body(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); +} + +void draw_snake_head(int u, int v) +{ + //May need to design a snake head sprite + //Tile still need to be designed on paper + + uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); +} + +void draw_snake_tail(int u, int v) +{ + //May need to design a snake tail sprite + //Tile still need to be designed on paper + uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); +} + +