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:
@@ -127,8 +127,8 @@ function draw()
|
||||
renderer.line(cell_x + 2, cell_y + 2, cell_x + CELL_SIZE - 2, cell_y + CELL_SIZE - 2, true, 1)
|
||||
renderer.line(cell_x + CELL_SIZE - 2, cell_y + 2, cell_x + 2, cell_y + CELL_SIZE - 2, true, 1)
|
||||
elseif value == 2 then
|
||||
-- Draw O
|
||||
renderer.circle(cell_x + CELL_SIZE / 2, cell_y + CELL_SIZE / 2, CELL_SIZE / 2 - 2, true, false)
|
||||
-- Draw O (convert center to integers)
|
||||
renderer.circle(math.floor(cell_x + CELL_SIZE / 2 + 0.5), math.floor(cell_y + CELL_SIZE / 2 + 0.5), CELL_SIZE / 2 - 2, true, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user