Skip to content

Commit

Permalink
refactored types
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Sep 1, 2020
1 parent e15a887 commit baa0e61
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/game.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
screenHeight = 450;
ballSpeedMin = 6;
ballSpeedMax = 16;
ballSize = 8;
barSpeed = 12;
ballSize : Single = 8;
barSpeed : Single = 12;
barSize : TVector2 = (x: 8 ; y: 80);

var
Expand Down Expand Up @@ -41,7 +41,7 @@
ball.y := screenHeight div 2;
ballSpeed.x := -ballSpeedMin;
ballSpeed.y := Randomrange(-ballSpeedMin, ballSpeedMin);
player := RectangleCreate(round(padding), round((screenHeight div 2) - (round(barSize.y) div 2)), round(barSize.x), round(barSize.y));
player := RectangleCreate(padding, Trunc(screenHeight / 2) - Trunc(barSize.y / 2), Trunc(barSize.x), Trunc(barSize.y));
end;
// game code
if not pause then begin
Expand All @@ -54,9 +54,9 @@
if IsKeyDown(KEY_UP) then player.y := max(player.y - barSpeed, 0);
if IsKeyDown(KEY_DOWN) then player.y := min(player.y + barSpeed, screenHeight - barSize.y);
// ball move
if round(ball.x) < ballSize then reset := true; // game over
if round(ball.x) > (screenWidth - ballSize) then ballSpeed.x := max(ballSpeed.x * -1.1, -ballSpeedMax);
if (round(ball.y) < ballSize) or (round(ball.y) > (screenHeight - ballSize)) then ballSpeed.y := -ballSpeed.y;
if ball.x < ballSize then reset := true; // game over
if ball.x > (screenWidth - ballSize) then ballSpeed.x := max(ballSpeed.x * -1.1, -ballSpeedMax);
if (ball.y < ballSize) or (ball.y > (screenHeight - ballSize)) then ballSpeed.y := -ballSpeed.y;
ball := Vector2Add(ball, ballSpeed);
end;
// rendering
Expand Down

0 comments on commit baa0e61

Please sign in to comment.