ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

Committer:
el19tb
Date:
Wed May 06 16:53:18 2020 +0000
Revision:
4:aae7f8d4ab78
Parent:
3:648c9d5001be
Child:
5:6e3afee7eac3
Made the code more structured, added different vehicle types;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el19tb 3:648c9d5001be 1 #include "GraphicEngine.h"
el19tb 3:648c9d5001be 2
el19tb 3:648c9d5001be 3 N5110 lcd;
el19tb 3:648c9d5001be 4 GraphicEngine::GraphicEngine(Chicken *chicken){
el19tb 3:648c9d5001be 5 this->chick = chicken;
el19tb 3:648c9d5001be 6 }
el19tb 3:648c9d5001be 7
el19tb 3:648c9d5001be 8 void GraphicEngine::init(){
el19tb 3:648c9d5001be 9 lcd.init();
el19tb 3:648c9d5001be 10 }
el19tb 3:648c9d5001be 11
el19tb 3:648c9d5001be 12 void GraphicEngine::showChicken(){
el19tb 3:648c9d5001be 13 //fill the chicken with black color
el19tb 4:aae7f8d4ab78 14 lcd.drawRect(chick->x, chick->y, chick->width, chick->width, FILL_BLACK);
el19tb 3:648c9d5001be 15 }
el19tb 3:648c9d5001be 16
el19tb 4:aae7f8d4ab78 17 // TO DO:
el19tb 4:aae7f8d4ab78 18 // -> make multiple lanes of cars (first manually then automatically)
el19tb 4:aae7f8d4ab78 19 // -> make one lane go other direction
el19tb 4:aae7f8d4ab78 20 // -> make a safety lane
el19tb 4:aae7f8d4ab78 21 // -> make a logs
el19tb 4:aae7f8d4ab78 22 // -> make turtles
el19tb 4:aae7f8d4ab78 23 // -> make the ocean (if collision with ocean then dead)
el19tb 4:aae7f8d4ab78 24 // -> make multiple lives
el19tb 4:aae7f8d4ab78 25 // -> point system
el19tb 4:aae7f8d4ab78 26 // -> make the sprite images
el19tb 4:aae7f8d4ab78 27 // -> make background object (sprite of entire screen)
el19tb 4:aae7f8d4ab78 28 // -> make menu screen
el19tb 4:aae7f8d4ab78 29 // -> collision
el19tb 4:aae7f8d4ab78 30 // -> make sprite of safety lanes
el19tb 4:aae7f8d4ab78 31 // -> make snake object
el19tb 4:aae7f8d4ab78 32 // BONUS:
el19tb 4:aae7f8d4ab78 33 // --> make multiple levels
el19tb 4:aae7f8d4ab78 34 // --> time constraint
el19tb 4:aae7f8d4ab78 35
el19tb 4:aae7f8d4ab78 36 void GraphicEngine::showCar(Car *car){
el19tb 4:aae7f8d4ab78 37 // safety lane
el19tb 4:aae7f8d4ab78 38 lcd.drawRect(0, 48 - 4, 84, 4, FILL_TRANSPARENT);
el19tb 4:aae7f8d4ab78 39 lcd.drawRect(0, 48 - 4*6, 84, 4, FILL_TRANSPARENT);
el19tb 4:aae7f8d4ab78 40
el19tb 4:aae7f8d4ab78 41 lcd.drawRect(car->left_car.x, car->left_car.y, car->left_car.height, car->left_car.width, FILL_BLACK);
el19tb 3:648c9d5001be 42 }
el19tb 3:648c9d5001be 43
el19tb 3:648c9d5001be 44 void GraphicEngine::contrast(){
el19tb 3:648c9d5001be 45 lcd.setContrast(0.4);
el19tb 3:648c9d5001be 46 }
el19tb 3:648c9d5001be 47
el19tb 3:648c9d5001be 48 void GraphicEngine::clear(){
el19tb 3:648c9d5001be 49 lcd.clear();
el19tb 3:648c9d5001be 50 }
el19tb 3:648c9d5001be 51
el19tb 3:648c9d5001be 52 void GraphicEngine::refresh(){
el19tb 3:648c9d5001be 53 lcd.refresh();
el19tb 3:648c9d5001be 54 }
el19tb 3:648c9d5001be 55
el19tb 3:648c9d5001be 56 void GraphicEngine::backLightOn(){
el19tb 3:648c9d5001be 57 lcd.backLightOn();
el19tb 3:648c9d5001be 58 }