Fix Lua game float-to-int conversion errors for renderer.circle()

All games had the same issue: renderer.circle() requires integer arguments,
but float calculations produced non-integer coordinates.

Fixed in all games using math.floor(x + 0.5) for proper rounding:
- pong.lua: Ball position
- air_hockey.lua: Puck position
- asteroids.lua: Asteroid positions
- ball.lua: Ball and trail positions, velocity line
- breakout.lua: Ball position
- flappy_bird.lua: Bird Y position
- counter.lua: Last touch marker position
- snake.lua: Food position (center calculation)
- tic_tac_toe.lua: O circle center position

Also fixed floating-point coordinate calculations in ball and line
drawing to ensure all coordinates are integers.
This commit is contained in:
Adolfo Reyna
2026-02-12 20:51:26 -05:00
parent b5e69abc83
commit b22170b62c
9 changed files with 22 additions and 22 deletions

View File

@@ -111,8 +111,8 @@ function draw()
-- Draw paddle
renderer.rect(game.vars.paddle_x, game.height() - PADDLE_HEIGHT - 2, PADDLE_WIDTH, PADDLE_HEIGHT, true, true)
-- Draw ball
renderer.circle(game.vars.ball_x, game.vars.ball_y, BALL_RADIUS, true, true)
-- Draw ball (convert to integers)
renderer.circle(math.floor(game.vars.ball_x + 0.5), math.floor(game.vars.ball_y + 0.5), BALL_RADIUS, true, true)
-- Draw score and lives
renderer.text(5, 5, "Score: " .. tostring(game.vars.score), true)