Reverse ball on pipe contact, reset on pipe miss

This commit is contained in:
Yannick Reiß 2024-08-24 18:39:52 +02:00
parent 1b11f5ffe3
commit 594bd80581
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
1 changed files with 18 additions and 1 deletions

View File

@ -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