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: CrossyChicken/CrossyChicken.cpp
- Revision:
- 4:aae7f8d4ab78
- Parent:
- 3:648c9d5001be
- Child:
- 5:6e3afee7eac3
diff -r 648c9d5001be -r aae7f8d4ab78 CrossyChicken/CrossyChicken.cpp
--- a/CrossyChicken/CrossyChicken.cpp Mon May 04 03:55:03 2020 +0000
+++ b/CrossyChicken/CrossyChicken.cpp Wed May 06 16:53:18 2020 +0000
@@ -12,17 +12,15 @@
//algoritmic way of generating lanes
//size of each each tile in the game
-int grid = 8;
-int heightLcd = 48;
-int widthLcd = 84;
+int grid = 4;
//make one object of chicken
//use this to move around the lcd
-Chicken chicken(6, 6, 6);
+Chicken chicken((84/2)-4/2, 48-4, 4);
Chicken *chickenptr= &chicken;
//there will be multiple cars
-Car cars[4];
+std::vector<Car> cars;
//class that whill show objects
GraphicEngine graphics(chickenptr);
@@ -34,17 +32,18 @@
graphics.contrast();
graphics.backLightOn();
gamepad.init();
-
+
+ for (int i = 0; i < 4; i++){
+ Car car;
+ cars.push_back(car);
+ }
+
//keep reading and processing user input
while(1) {
graphics.clear();
graphics.showChicken();
+ process_input();
moveCar();
- //move();
- //check if they have interesected
-
- graphics.showChicken();
- process_input();
graphics.refresh();
wait_ms(100);
}
@@ -70,10 +69,10 @@
//moves the chicken around the grid
void CrossyChicken::moveChicken(int xWay, int yWay){
//increment the left side of the chicken by a value of the grid size
- chicken.leftSide += xWay * 8;
+ chicken.x += xWay * 4;
//increment the top side by a value of grid sizw
- chicken.topSide += yWay * 8;
+ chicken.y += yWay * 4;
//display the new state of the chicken
graphics.showChicken();
@@ -82,12 +81,21 @@
}
void CrossyChicken::moveCar() {
- for(int y = 0; y < 3; y++){
- cars[y].update();
- graphics.showCar(cars);
+ std::vector<Car>::size_type t;
+
+
+
+ //for(int t = 0; t != cars.size(); t++){
+ //set the seperation of the first row
+ cars.at(0).setRow(4);
+
+ Car *carptr = &cars[0];
- // if((cars[y].collision(chickenptr))){
- // cars[y].stop();
- //}
- }
+ carptr->speedMedium(2);
+ //carptr->left_car.x += 0.2;
+
+ carptr->setSeperation(0);
+
+ graphics.showCar(carptr);
+ //}
}
\ No newline at end of file