ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

Revision:
5:6e3afee7eac3
Child:
7:1dce07fd0867
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Frog/Car.cpp	Thu May 07 05:35:50 2020 +0000
@@ -0,0 +1,67 @@
+#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 = 2; 
+    
+    // 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;
+}
+
+