project for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
kblake9
Date:
Wed Nov 25 00:52:57 2020 +0000
Revision:
19:58cd419a082c
Parent:
18:92431a28b46b
Child:
20:0c0fec831df0
refined awful snake design

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 {
kblake9 19:58cd419a082c 50 uLCD.filled_rectangle(u, v, u+10, v+10, WHITE);
kblake9 19:58cd419a082c 51 uLCD.line(u+2, v, u+2, v+11, RED);
DCchico 1:10330bce85cb 52 }
DCchico 1:10330bce85cb 53
DCchico 1:10330bce85cb 54 void draw_snake_head(int u, int v)
DCchico 1:10330bce85cb 55 {
DCchico 1:10330bce85cb 56 //May need to design a snake head sprite
DCchico 1:10330bce85cb 57 //Tile still need to be designed on paper
DCchico 1:10330bce85cb 58
kblake9 19:58cd419a082c 59 uLCD.filled_rectangle(u, v, u+10, v+10, BLUE);
kblake9 10:7f96ff75b7a5 60 uLCD.pixel(u+8, v+2, RED);
kblake9 18:92431a28b46b 61 uLCD.line(u+2, v+8, u+10, v+8, RED);
DCchico 1:10330bce85cb 62 }
DCchico 1:10330bce85cb 63
DCchico 1:10330bce85cb 64 void draw_snake_tail(int u, int v)
DCchico 1:10330bce85cb 65 {
DCchico 1:10330bce85cb 66 //May need to design a snake tail sprite
DCchico 1:10330bce85cb 67 //Tile still need to be designed on paper
kblake9 19:58cd419a082c 68 uLCD.filled_rectangle(u, v, u+10, v+10, BLUE);
DCchico 1:10330bce85cb 69 }