project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
graphics.cpp
- Committer:
- kblake9
- Date:
- 2020-11-25
- Revision:
- 18:92431a28b46b
- Parent:
- 11:20e5a1b9b1af
- Child:
- 19:58cd419a082c
File content as of revision 18:92431a28b46b:
// Copyright 2020 Georgia Tech. All rights reserved. // The materials provided by the instructor in this course are for // the use of the students currently enrolled in the course. // Copyrighted course materials may not be further disseminated. // This file must not be made publicly available anywhere. #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); uLCD.pixel(u+8, v+2, RED); uLCD.line(u+2, v+8, u+10, v+8, RED); } 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); uLCD.line(u+1, v+2, u+1, v+8, RED); }