bouncing_ball backend
Fork of bouncing_ball by
Diff: bouncing_ball.cpp
- Revision:
- 3:30b5a3adc15f
- Parent:
- 2:ba1844b0eb9f
- Child:
- 4:73a00b0667fc
--- a/bouncing_ball.cpp Tue Nov 07 12:07:13 2017 +0000 +++ b/bouncing_ball.cpp Tue Nov 07 14:28:53 2017 +0000 @@ -64,9 +64,19 @@ // Make circle bounce off of edges if at the edges: if (( posx <= radius) || ((posx + radius) >= _width)) { speedx = -speedx; + if ( posx <= radius){ + _posx_f+=radius; + } else { + _posx_f-=radius; + } } if (( posy <= radius) || ((posy + radius) >= _height)) { speedy = -speedy; + if ( posy <= radius){ + _posy_f+=radius; + } else { + _posy_f-=radius; + } } //Accelerate per actual real world physics: