![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
graphics.cpp
- Committer:
- DCchico
- Date:
- 2020-10-23
- Revision:
- 1:10330bce85cb
- Child:
- 2:4947d6a82971
File content as of revision 1:10330bce85cb:
#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); }