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.
Diff: Paddle/Paddle.cpp
- Revision:
- 72:7254d2a8a1cd
- Parent:
- 69:db1354676fde
- Child:
- 74:dfb1d693d8e3
diff -r 886cde5e2c63 -r 7254d2a8a1cd Paddle/Paddle.cpp
--- a/Paddle/Paddle.cpp	Sun May 05 16:47:19 2019 +0000
+++ b/Paddle/Paddle.cpp	Sun May 05 17:36:35 2019 +0000
@@ -19,7 +19,8 @@
     _y = y;  // y depends on height of screen and height of paddle
     _height = height;
     _width = width;
-    _speed = 1;  // default speed
+    _sens = 0.75;
+    _speed = 3;  // default speed
     _score = 0;  // start score from zero
     _lives = 6;
     _tilt = false; //use to choose between motion methods
@@ -42,9 +43,9 @@
         // update y value depending on direction of movement
         // North is decrement as origin is at the top-left so decreasing moves up
         if (d == W) {
-            _x-=_speed;
+            _x-=_speed * _sens;
         } else if (d == E) {
-            _x+=_speed;
+            _x+=_speed * _sens;
         }
     
         // check the y origin to ensure that the paddle doesn't go off screen
@@ -63,7 +64,7 @@
     
         // update y value depending on direction of movement
         // North is decrement as origin is at the top-left so decreasing moves up
-        _x -= _speed;
+        _x -= _speed * _sens;
     }
 
     // check the y origin to ensure that the paddle doesn't go off screen
@@ -113,3 +114,8 @@
 {
     _x = WIDTH/2 - 15/2;  // x value on screen is fixed
 }
+
+void Paddle::set_sens(float sens) 
+{
+    _sens = sens;
+}