project for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
kblake9
Date:
Tue Nov 24 10:26:05 2020 +0000
Revision:
4:b687219ae447
Parent:
2:4947d6a82971
Child:
7:1912b4a2e4fe
setting stuff up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 2:4947d6a82971 1 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 2:4947d6a82971 2 // The materials provided by the instructor in this course are for
DCchico 2:4947d6a82971 3 // the use of the students currently enrolled in the course.
DCchico 2:4947d6a82971 4 // Copyrighted course materials may not be further disseminated.
DCchico 2:4947d6a82971 5 // This file must not be made publicly available anywhere.
DCchico 2:4947d6a82971 6
DCchico 1:10330bce85cb 7 #include "graphics.h"
DCchico 1:10330bce85cb 8
DCchico 1:10330bce85cb 9 #include "globals.h"
DCchico 1:10330bce85cb 10
DCchico 1:10330bce85cb 11 void draw_nothing(int u, int v)
DCchico 1:10330bce85cb 12 {
DCchico 1:10330bce85cb 13 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
DCchico 1:10330bce85cb 14 }
DCchico 1:10330bce85cb 15
DCchico 1:10330bce85cb 16 void draw_img(int u, int v, const char* img)
DCchico 1:10330bce85cb 17 {
DCchico 1:10330bce85cb 18 int colors[11*11];
DCchico 1:10330bce85cb 19 for (int i = 0; i < 11*11; i++)
DCchico 1:10330bce85cb 20 {
DCchico 1:10330bce85cb 21 if (img[i] == 'R') colors[i] = RED;
DCchico 1:10330bce85cb 22 else if (img[i] == 'Y') colors[i] = 0xFFFF00; // Yellow
DCchico 1:10330bce85cb 23 else if (img[i] == 'G') colors[i] = GREEN;
DCchico 1:10330bce85cb 24 else if (img[i] == 'D') colors[i] = 0xD2691E; // "Dirt"
DCchico 1:10330bce85cb 25 else if (img[i] == '5') colors[i] = LGREY; // 50% grey
DCchico 1:10330bce85cb 26 else if (img[i] == '3') colors[i] = DGREY;
DCchico 1:10330bce85cb 27 else colors[i] = BLACK;
DCchico 1:10330bce85cb 28 }
DCchico 1:10330bce85cb 29 uLCD.BLIT(u, v, 11, 11, colors);
DCchico 1:10330bce85cb 30 wait_us(250); // Recovery time!
DCchico 1:10330bce85cb 31 }
DCchico 1:10330bce85cb 32
DCchico 1:10330bce85cb 33 void draw_wall(int u, int v)
DCchico 1:10330bce85cb 34 {
DCchico 1:10330bce85cb 35 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
DCchico 1:10330bce85cb 36 }
DCchico 1:10330bce85cb 37
DCchico 1:10330bce85cb 38 void draw_plant(int u, int v)
DCchico 1:10330bce85cb 39 {
DCchico 1:10330bce85cb 40 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 41 }
DCchico 1:10330bce85cb 42
DCchico 1:10330bce85cb 43 void draw_goodie(int u, int v)
DCchico 1:10330bce85cb 44 {
DCchico 1:10330bce85cb 45 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 46 }
DCchico 1:10330bce85cb 47
DCchico 1:10330bce85cb 48 void draw_snake_body(int u, int v)
DCchico 1:10330bce85cb 49 {
DCchico 1:10330bce85cb 50 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 51 }
DCchico 1:10330bce85cb 52
DCchico 1:10330bce85cb 53 void draw_snake_head(int u, int v)
DCchico 1:10330bce85cb 54 {
DCchico 1:10330bce85cb 55 //May need to design a snake head sprite
DCchico 1:10330bce85cb 56 //Tile still need to be designed on paper
DCchico 1:10330bce85cb 57
DCchico 1:10330bce85cb 58 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
kblake9 4:b687219ae447 59 uLCD.pixel(u+8, v+2, RED);
kblake9 4:b687219ae447 60 uLCD.line(u+2, v+8, RED);
DCchico 1:10330bce85cb 61 }
DCchico 1:10330bce85cb 62
DCchico 1:10330bce85cb 63 void draw_snake_tail(int u, int v)
DCchico 1:10330bce85cb 64 {
DCchico 1:10330bce85cb 65 //May need to design a snake tail sprite
DCchico 1:10330bce85cb 66 //Tile still need to be designed on paper
DCchico 1:10330bce85cb 67 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
kblake9 4:b687219ae447 68 uLCD.pixel(u+10, v+2, RED);
kblake9 4:b687219ae447 69 uLCD.pixel(u+10, v+8, RED);
DCchico 1:10330bce85cb 70 }
DCchico 1:10330bce85cb 71
DCchico 1:10330bce85cb 72