James Cummins / Mbed 2 deprecated el17jnc

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
JamesCummins
Date:
Thu May 09 10:52:00 2019 +0000
Parent:
39:dfc489594f11
Commit message:
Final Submission. I have read and agreed with Statement of Academic Integrity.

Changed in this revision

Ball/Ball.cpp Show annotated file Show diff for this revision Revisions of this file
Ball/ball_test.h Show annotated file Show diff for this revision Revisions of this file
Classic_Engine/ClassicEngine.cpp Show annotated file Show diff for this revision Revisions of this file
Map/Map.cpp Show annotated file Show diff for this revision Revisions of this file
Map/Map.h Show annotated file Show diff for this revision Revisions of this file
Map/map_test.h Show annotated file Show diff for this revision Revisions of this file
Options_Engine/OptionsEngine.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
tests.h Show annotated file Show diff for this revision Revisions of this file
--- a/Ball/Ball.cpp	Thu May 09 01:58:36 2019 +0000
+++ b/Ball/Ball.cpp	Thu May 09 10:52:00 2019 +0000
@@ -24,8 +24,6 @@
     Data values = accelerometer.get_values();
     _velocity.x = -(5+_ball_speed)*values.ay;        //axes of the accelerometer are different to orientation of the screen
     _velocity.y = -(5+_ball_speed)*values.ax;        //negative to account for reversed direction
-    /*printf("ax = %f | ay = %f     |        ", values.ax, values.ay);
-    printf("vel.x = %f | vel.y = %f\n", _velocity.x, _velocity.y);*/
 }
 
 void Ball::update(){
--- a/Ball/ball_test.h	Thu May 09 01:58:36 2019 +0000
+++ b/Ball/ball_test.h	Thu May 09 10:52:00 2019 +0000
@@ -8,7 +8,7 @@
 
 bool ball_test(){
     Ball ball;      //create ball object
-    ball.init(3)    //set radius to 3
+    ball.init(3);    //set radius to 3
     Vector2D ball_pos = {10, 20};       //give ball initial position of (10,20)
     ball.set_position(ball_pos);
     Vector2D ball_vel = {3, -5};        //give ball initial velocity of (3, -5)
--- a/Classic_Engine/ClassicEngine.cpp	Thu May 09 01:58:36 2019 +0000
+++ b/Classic_Engine/ClassicEngine.cpp	Thu May 09 10:52:00 2019 +0000
@@ -43,7 +43,6 @@
            finished = true;             //will never exactly equal 402
     }
     else{ finished = false; }
-    printf("ball pos = %f , %f   |   finished = %d\n", _abs_ball_pos.x, _abs_ball_pos.y, finished);
     return finished;        //tell the game mode that the ball's reached the end of the course
 }
 
--- a/Map/Map.cpp	Thu May 09 01:58:36 2019 +0000
+++ b/Map/Map.cpp	Thu May 09 10:52:00 2019 +0000
@@ -14,8 +14,8 @@
 void Map::read_input(FXOS8700CQ &accelerometer, Ball &ball){
     Data values = accelerometer.get_values();
     int ball_speed = ball.get_ball_speed();     //get the sensitivity from ball object
-    _map_change.x = -(1+0.5*ball_speed)*values.ay;      //axes of accelerometer different to gamepad so use -y for x and vice versa
-    _map_change.y = -(1+0.5*ball_speed)*values.ax;
+    _map_change.x = -0.25*(1+0.5*ball_speed)*values.ay;      //axes of accelerometer different to gamepad so use -y for x and vice versa
+    _map_change.y = -0.25*(1+0.5*ball_speed)*values.ax;
 }
 
 void Map::update(){
@@ -67,18 +67,17 @@
         int x = ball_pixels[i].x;
         if(gamemap[y][x] == 1){         //check each pixel in the ball to see if it is on a '1' in game map (representing wall)
             collision = true;
-            printf("colliding pixel = %d,%d\n", x, y);
             break;          //break with true if wall collision
         } else { collision = false; }       //keep iterating if not
     }
     return collision;
 }
 
-bool Map::get_coordinate(Vector2D coord){
-    bool position;
+int Map::get_coordinate(Vector2D coord){
+    int position;
     int x = coord.x;
     int y = coord.y;
-    if(gamemap[y][x] == 1){ position == true; } //find the desired coord in the game map
-    else{ position == false; }      //return true if its a wall, false if it's pathway
+    if(gamemap[y][x] == 1){ position = 1; } //find the desired coord in the game map
+    else{ position = 0; }      //return true if its a wall, false if it's pathway
     return position;
 }
\ No newline at end of file
--- a/Map/Map.h	Thu May 09 01:58:36 2019 +0000
+++ b/Map/Map.h	Thu May 09 10:52:00 2019 +0000
@@ -114,11 +114,11 @@
     * @brief Get whether a coordinate in the game map is assigned a '1' or a '0'
     * @param coord - 2D vector of the x and y coordinates of the desired point
     * @returns
-    *       true - coordinate contains a '1'
-    *       false - coordinate contains a '0'
+    *       1 - coordinate contains a '1'
+    *       0 - coordinate contains a '0'
     * @details Method included for testing purposes rather than use in game code
     */
-    bool get_coordinate(Vector2D coord);
+    int get_coordinate(Vector2D coord);
 
     
 private: 
--- a/Map/map_test.h	Thu May 09 01:58:36 2019 +0000
+++ b/Map/map_test.h	Thu May 09 10:52:00 2019 +0000
@@ -11,15 +11,23 @@
     map.init();
     bool passed = true;
     Vector2D coord = {0,0};     //top left coord
+    printf("Running...\n");
     
-    if (map.get_coordinate(coord) != true) { passed = false; }      //test 1
-    coord = {60,60};        //start area coord
-    if (map.get_coordinate(coord) != 0) { passed = false; }         //test 2
-    coord = {224,590};      //bottom right coord
-    if (map.get_coordinate(coord) != 1) { passed = false; }         //test 3
-    coord = {405,120};      //finish area coord
-    if (map.get_coordinate(coord) != 0) { passed = false; }         //test 4
+    int pixel = map.get_coordinate(coord);
+    printf("1st pixel = %d\n", pixel);
+    if (pixel != 1) {      //test 1 - test what should be a black pixel
+        passed = false;
+        printf("Coord 1 failed\n");
+        }
+    coord.x = 60;        //start area coord
+    coord.y = 60;
     
+    pixel = map.get_coordinate(coord);
+    printf("2nd pixel = %d\n", pixel);
+    if (pixel != 0) {         //test 2 - test what should be a white pixel
+        passed = false;
+        printf("Coord 2 failed\n");
+        }
     return passed;
 }
 
--- a/Options_Engine/OptionsEngine.cpp	Thu May 09 01:58:36 2019 +0000
+++ b/Options_Engine/OptionsEngine.cpp	Thu May 09 10:52:00 2019 +0000
@@ -60,7 +60,6 @@
     if(gamepad.check_event(gamepad.R_PRESSED)){ _brightness += 0.1f; }      //Otherwise 0.1 is implicitly converted to a double (giving warning messages).
     if(_brightness < 0){ _brightness = 0; }     //keep within range of 0 - 1
     if(_brightness > 1){ _brightness = 1; }
-    /*printf("Brightness = %f\n", _brightness);*/
 }
 
 void OptionsEngine::change_ball_speed(Gamepad &gamepad, N5110 &lcd, Ball &ball){
--- a/main.cpp	Thu May 09 01:58:36 2019 +0000
+++ b/main.cpp	Thu May 09 10:52:00 2019 +0000
@@ -17,7 +17,7 @@
 #include "SDFileSystem.h"
 
 #ifdef WITH_TESTS
-    #include "tests.h"
+#include "tests.h"
 #endif
 
 #define RADIUS 3
@@ -64,13 +64,13 @@
 int fps = 16;   //declared globally so it doesn't have to be passed to
                 //the different game mode functions
 int main(){
-    
+    init();             //first initialise all objects   
+     
 #ifdef WITH_TESTS                                   //run tests to check code is correct
     int test_failures = no_of_tests_failed();
-    if(test_failures > 0){ return test_failures; }      //main function returns no of failures
+    if(test_failures > 0) return test_failures;      //main function returns no of failures
 #endif
-    
-    init();             //first initialise all objects
+
     startscreen();      //then display the introductory screen
     while(1){                //keep game running until power is removed
         StartOption choice_selected = menu();           //get which mode user wants from the start menu
--- a/tests.h	Thu May 09 01:58:36 2019 +0000
+++ b/tests.h	Thu May 09 10:52:00 2019 +0000
@@ -12,10 +12,11 @@
 int no_of_tests_failed(){
     //initialise failures to 0
     int quantity_failed = 0;
+    
     //run ball test
     printf("Testing ball movement:\n");
     bool balltest = ball_test();
-    //print results to terminal and increment failure count if failed
+        //print results to terminal and increment failure count if failed
     if(balltest){ printf("Ball test passed.\n"); }
     else if (!(balltest)){
         printf("Ball test failed!\n");
@@ -24,7 +25,7 @@
     //run map test
     printf("Testing map pixel reading:\n");
     bool maptest = map_test();
-    //print results to terminal and increment failure count if failed
+            //print results to terminal and increment failure count if failed
     if(maptest) {printf("Map test passed.\n"); }
     else if (!(maptest)){
         printf("Map test failed!\n");