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:
- 33:011f0f7cf3ce
- Parent:
- 31:70521f37e004
- Child:
- 35:db257b7bdefc
diff -r 84e79aa7858c -r 011f0f7cf3ce GraphicEngine/GraphicEngine.cpp
--- a/GraphicEngine/GraphicEngine.cpp Sat May 16 05:22:26 2020 +0000
+++ b/GraphicEngine/GraphicEngine.cpp Sat May 16 06:28:48 2020 +0000
@@ -1,229 +0,0 @@
-#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);
-}
-
-void GraphicEngine::createSafetyLanes(const std::vector<Safety>& safety_lane)
-{
- Safety temp;
- for(unsigned int i = 0; i < safety_lane.size(); i++){
- temp.x = safety_lane[i].x;
- temp.row = safety_lane[i].row;
- temp.c = safety_lane[i].c;
-
- drawIndividualSafety(temp);
- }
-}
-
-void GraphicEngine::drawIndividualSafety(&Safety lane_obj)
-{
- switch(lane_obj.c)
- {
- case 'K':
- lcd.drawSprite(lane_obj.x, 48 - 4*lane_obj.row, 4, 4, (int *)safety_lanes_one);
- break;
- case 'K':
- lcd.drawSprite(lane_obj.x, 48 - 4*lane_obj.row, 4, 4, (int *)safety_lanes_two);
- break;
- }
-}
-
-void GraphicEngine::drawFirstSafetyBackground(int x, int row)
-{
- lcd.drawSprite(x, 48 - 4*row, 4, 4, (int *)safety_lanes_one);
-}
-
-void GraphicEngine::drawSecondSafetyBackground(int x, int row)
-{
- lcd.drawSprite(x, 48 - 4*row, 4, 4, (int *)safety_lane_two);
-)
-
-void GraphicEngine::drawGoal(int x, int row)
-{
- lcd.drawSprite(x, row, 8, 8, (int *)end_post);
-}
-
-// this is just going to be white blocks
-// road == '.'
-void GraphhicEngine::drawRoads(int row)
-{
- // draw across the screen width
- for(int a = 0; a < 22; a++){
- showEachRoad(a, row); // x pos is the value of a
- }
-}
-
-void GraphicEngine::showEachRoad(int x, int row)
-{
- lcd.drawSprite(x, 48 - 4*row,4, 4, (int *)road);
-}
-
-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 screen0
- // create an enum to determine the vehicle type
- for(int y = 0; y < 4; y++){
- showIndividualCar(&car[y]);
- }
-}
-
-void GraphicEngine::displayVehicle(int x, int row, char c)
-{
- switch(obj)
- {
- case 'L': lcd.drawSprite(x, 48 - 4y, 4, 4, (int *)left_racer);
- break;
- case 'R' : lcd.drawSprite(x, 48 - 4*y, 4, 4, (int *)right_racer);
- break;
- case 'B': lcd.drawSprite(x, 48 - 4*y, 4, 6, (int *)bus);
- break;
- case 'N': lcd.drawSprite(x, 48 - 4*y, 4, 4, (int *)right_normal);
- break;
- case 'X': lcd.drawSprite(x, 48 - 4*y, 4, 4, (int *)left_normal);
- break;
- case '-': lcd.drawSprite(x, 48 - 4*y, 4, 4, FILL_WHITE);
- break;
- }
-}
-
-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::showWater(Water *water)
-{
- for(int i = 0; i < 22; i++)
- {
- showIndividualWater(&water[i]);
- }
-}
-
-void GraphicEngine::showIndividualWater(Water *water)
-{
- // POTENTIAL BUG, add break later
- switch(water->sprite){
- case 'F':
- displayFirstWater(water);
- case 'S':
- displaySecondWater(water);
- case 'T':
- displayThirdWater(water);
- }
-}
-
-void GraphicEngine::drawWater(std::vector<Water> &water_lane)
-{
- Water temp;
- for(unsigned int i = 0; i < water_lane.size(); i++)
- {
- temp.x = water_lane[i].x;
- temp.row = water_lane[i].row;
- temp.char = water_lane[i].c;
-
- drawIndividualWater(&temp);
- }
-}
-
-void GraphicEngine::showIndividualWater(Water &temp)
-{
- switch(temp.c)
- {
- case 'F':
- lcd.drawSprite(temp.x,48 - 4*temp.y, 4, 4, (int *)first_water);
- break;
- case 'S':
- lcd.drawSprite(temp.x,48 - 4*temp.y, 4, 4, (int *)second_water);
- break;
- case 'T':
- lcd.drawSprite(temp.x, 48 - 4*temp.y, 4, 4, (int *)third_water);
- break;
- }
-}
-
-// water = ','
-void GraphicEngine::drawWater(char water, int x, int y, int row, in col)
-{
- int rand_water = 0;
- rand_water = (rand() % 3) + 1;
-
- // for design purposes the water will have different sprites
- switch(rand_water)
- {
- case 1:
- lcd.drawSprite(x, y, rows, cols, (int *)first_water);
-
- case 2:
- lcd.drawSprite(x, y, rows, cols, (int *)second_water);
-
- case 3:
- lcd.drawSprite(x, y, rows, cols, (int *)third_water);
- }
-}
-
-void GraphicEngine::displayCar(DrawCar &size)
-{
- lcd.drawRect(size.x, size.y, size.width, size.height, FILL_TRANSPARENT);
-}
-
-void GraphicEngine::getRoadObjects(const std::vector<Background>& road_lanes)
-{
- DrawRoad road;
-
- for(unsigned int i = 0; i < road_lanes.size(); i++)
- {
- road.x = road_lanes[i].x;
- road.row = road_lanes[i].row;
- drawIndividualRoadObj(road);
- }
-}
-
-void GraphicEngine::drawIndividualRoadObj(DrawRoad &obj)
-{
- lcd.drawSprite(obj.x, 48 - 4*obj.y, 4, 4, (int *) road);
-}
-
-void GraphicEngine::printTest(){
- lcd.printString("SQUISHED", 1, 1);
-}
-
-void GraphicEngine::print(){
- lcd.printString("DROWNED",1,1);
-}
-
-void GraphicEngine::contrast(){
- lcd.setContrast(0.4);
-}
-
-void GraphicEngine::clear(){
- lcd.clear();
-}
-
-void GraphicEngine::refresh(){
- lcd.refresh();
-}
-
-void GraphicEngine::backLightOn(){
- lcd.backLightOn();
-}
\ No newline at end of file