diff --git a/src/ballon_bounce.adb b/src/ballon_bounce.adb index 9c8c560..acfca3e 100644 --- a/src/ballon_bounce.adb +++ b/src/ballon_bounce.adb @@ -108,10 +108,27 @@ begin Ball_Direction.X := Ball_Direction.X * (-1.0); end if; - if (Ball_Y <= 0.0) or ((Ball_Y + Ball_Size) >= Height_Float) then + if Ball_Y <= 0.0 then Ball_Direction.Y := Ball_Direction.Y * (-1.0); end if; + -- Ball below platform! Possibly Lost! + if ((Ball_Y + Ball_Size) >= Platform_Y) then + Put_Line ("INFO: The Ball was catched at Y = " & Ball_Y'Image); + + -- Check if platform was hit, or game is lost + if ((Ball_X + (Ball_Size / 2.0)) >= Platform_X) and + ((Ball_X + (Ball_Size / 2.0)) <= (Platform_X + Platform_Width)) + then + Ball_Direction.Y := Ball_Direction.Y * (-1.0); + else + -- Game is Lost, reset for now + Ball_X := Width_Float / 2.0; + Ball_Y := Height_Float / 2.0; + Ball_Direction := (1.0, 1.0); + end if; + end if; + -- END: Computing area -- BEGIN: Update states