Dependencies:   mbed

Revision:
26:04b2d7742a84
Parent:
25:467d8fd0fec4
Child:
28:215e8327d4e6
--- a/Game/Game.cpp	Mon May 25 18:25:00 2020 +0000
+++ b/Game/Game.cpp	Mon May 25 19:36:07 2020 +0000
@@ -119,7 +119,8 @@
 void Game::updateSpeed() {
     if (abs(_speed) <= 3) { // max speed = 3
         if (_score % 3 == 0 && _score != _new_speed_threshold) {
-            _speed = abs(_speed) + 0.20f;
+            // add 0.2 everytime score hits a multiple of 3
+            _speed = abs(_speed) + 0.20f; 
             //update threshold so speed does not increase if score stays same
             _new_speed_threshold = _score;
         }
@@ -148,7 +149,8 @@
     sound_sample = 0;
     float val = 0.0f;
     int NUM_ELEMENTS = 0;
-    ticker.attach( & timer_isr, 226e-7);
+    ticker.attach( & timer_isr, 226e-7); //sample rate of sound effects
+    // set number of elements based on sound required
     if (sound == 1) { NUM_ELEMENTS = NUM_ELEMENTS_1; }
     else if (sound == 2) { NUM_ELEMENTS = NUM_ELEMENTS_3; } 
     else if (sound == 3) { NUM_ELEMENTS = NUM_ELEMENTS_2; } 
@@ -156,6 +158,7 @@
     while (sound_sample <= NUM_ELEMENTS) {
         if (sound_timer_flag == 1) {
             sound_timer_flag = 0;
+            //play sound effect based on input value 
             // convert from 0 to 255 to 0.0 to 1.0
             if (sound == 1) { val = float(miss[sound_sample]) / 256.0f; } 
             else if (sound == 2) { val = float(goall[sound_sample]) / 256.0f; }
@@ -268,6 +271,7 @@
     }
     _lcd -> refresh();
     wait(0.5);
+    // adding 1 offsets the range of inputs from 0-1 to 1-2 (needed for function)
     playGoalSound((int) _is_goal + 1);
     wait(1);
 }