Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: GraphicEngine/GraphicEngine.cpp
- Revision:
- 5:6e3afee7eac3
- Parent:
- 4:aae7f8d4ab78
- Child:
- 7:1dce07fd0867
diff -r aae7f8d4ab78 -r 6e3afee7eac3 GraphicEngine/GraphicEngine.cpp --- a/GraphicEngine/GraphicEngine.cpp Wed May 06 16:53:18 2020 +0000 +++ b/GraphicEngine/GraphicEngine.cpp Thu May 07 05:35:50 2020 +0000 @@ -1,18 +1,6 @@ #include "GraphicEngine.h" N5110 lcd; -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); -} // TO DO: // -> make multiple lanes of cars (first manually then automatically) @@ -29,16 +17,55 @@ // -> 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); - - lcd.drawRect(car->left_car.x, car->left_car.y, car->left_car.height, car->left_car.width, FILL_BLACK); + // 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(){