ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

GraphicEngine/GraphicEngine.cpp

Committer:
el19tb
Date:
2020-05-07
Revision:
5:6e3afee7eac3
Parent:
4:aae7f8d4ab78
Child:
7:1dce07fd0867

File content as of revision 5:6e3afee7eac3:

#include "GraphicEngine.h"

N5110 lcd;

// TO DO:
// -> make multiple lanes of cars (first manually then automatically)
// -> make one lane go other direction
// -> make a safety lane
// -> make a logs
// -> make turtles
// -> make the ocean (if collision with ocean then dead)
// -> make multiple lives
// -> point system
// -> make the sprite images
// -> make background object (sprite of entire screen)
// -> make menu screen
// -> collision
// -> make sprite of safety lanes
// -> make snake object
// -> make turtles disappear after a certain time
// BONUS:
// --> make multiple levels
// --> time constraint
// -> crocodile (level 3) only (jump on body)
// -> snake on log (level 3)

GraphicEngine::GraphicEngine(Chicken *chicken){
    this->chick = chicken;
}

void GraphicEngine::init(){
    lcd.init();
}

void GraphicEngine::showChicken(){
    //fill the chicken with black color
    lcd.drawRect(chick->x, chick->y, chick->width, chick->width, FILL_BLACK);
}

void GraphicEngine::showCar(Car *car){        
    // safety lane
    lcd.drawRect(0, 48 - 4, 84, 4, FILL_TRANSPARENT);
    lcd.drawRect(0, 48 - 4*6, 84, 4, FILL_TRANSPARENT);
        
    // draw to screen
    // create an enum to determine the vehicle type
    for(int y = 0; y < 2; y++){
        showIndividualCar(&car[y]);
    }
}

void GraphicEngine::showIndividualCar(Car *car){
    DrawCar temp_car;
    
    temp_car.x = car->vehicle.x;
    temp_car.y = car->vehicle.y;
    temp_car.width = car->vehicle.width;
    temp_car.height = car->vehicle.height;
    
    displayCar(temp_car);
}

void GraphicEngine::displayCar(DrawCar &size){
     lcd.drawRect(size.x, size.y, size.width, size.height, FILL_BLACK);
}

void GraphicEngine::printTest(){
    lcd.printString("SQUISHED", 1, 2);   
}

void GraphicEngine::contrast(){
    lcd.setContrast(0.4);   
}

void GraphicEngine::clear(){
    lcd.clear();
}

void GraphicEngine::refresh(){
    lcd.refresh();
}

void GraphicEngine::backLightOn(){
    lcd.backLightOn();
}