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
Frog/Car.cpp
- Committer:
- el19tb
- Date:
- 2020-05-11
- Revision:
- 7:1dce07fd0867
- Parent:
- 5:6e3afee7eac3
- Child:
- 8:52794de935b2
File content as of revision 7:1dce07fd0867:
#include "Car.h"
#include "CrossyChicken.h"
Car::Car(){
//different speeds of vehicles
slow = 0.4;
medium = 1.0;
fast = 1.5;
grid = 4;
seperation = 0;
screenHeight = 48;
screenWidth = 84;
size = 3;
// width of all vehicles
vehicle.width = grid * size;
}
void Car::setRow(int row){
this->row = row;
// y position of all vehicles
vehicle.y = screenHeight - grid * row;
// height of all vehicles
vehicle.height = grid;
}
void Car::setSeperation(int seperate){
this->seperation = seperate;
// intialize the vehicle size and position in lcd
// x position of all vehicles
vehicle.x = 8 + seperation;
}
void Car::speedSlow(){
speed = slow;
vehicle.x += slow;
}
void Car::speedMedium(int dir, int speed){
speed = medium;
//vehicle.x += speed;
switch(dir)
{
case 1:
vehicle.x += medium;
break;
case 2:
vehicle.x -= medium;
break;
}
}
void Car::speedFast(){
speed = fast;
vehicle.x += fast;
}