Fork of bouncing_ball by Stephen Licht

Revision:
6:1e5cd98fc2aa
Parent:
5:dd8df17df666
--- a/bouncing_ball.cpp	Tue Nov 14 14:57:59 2017 +0000
+++ b/bouncing_ball.cpp	Wed Nov 15 20:58:54 2017 +0000
@@ -63,20 +63,20 @@
 
         // Make circle bounce off of edges if at the edges:
         if (posx <= radius) {
+            posx = radius + BUFFER;
             speedx = -speedx;
-            posx = radius + BUFFER;
             }
         if ((posx + radius) >= _width) {
+            posx = _width - radius - BUFFER;
             speedx = -speedx;
-            posx = posx + radius - BUFFER;
             }
         if (posy <= radius) {
+            posy = radius + BUFFER;
             speedy = -speedy;
-            posy = radius + BUFFER;
             }
         if ((posy + radius) >= _height){
+            posy = _height - radius - BUFFER;
             speedy = -speedy;
-            posy = posy + radius - BUFFER;
             }
 
         //Accelerate per actual real world physics: