Correct draw offset for hits to right field.

This commit is contained in:
Sage Vaillancourt 2025-02-03 20:45:18 -05:00
parent 6dd8469409
commit 6308871692
1 changed files with 9 additions and 13 deletions

View File

@ -1,5 +1,3 @@
local ballBuffer <const> = 5
--- Assumes that background image is of size
--- XXX
--- XOX
@ -9,19 +7,17 @@ function getDrawOffset(screenW, screenH, ballX, ballY)
if ballY > screenH then
return 0, 0
end
if ballY < ballBuffer then
offsetY = math.max(ballBuffer, -1 * (ballY - ballBuffer))
else
offsetY = 0
end
if ballX > 0 and ballX < (screenW - ballBuffer) then
offsetY = math.max(0, -1 * ballY)
if ballX > 0 and ballX < screenW then
offsetX = 0
elseif ballX < ballBuffer then
offsetX = math.max(-1 * screenW, -1 * (ballX - ballBuffer))
elseif ballX > (screenW - ballBuffer) then
offsetX = math.min(screenW * 2, -1 * (ballX - ballBuffer))
elseif ballX < 0 then
offsetX = math.max(-1 * screenW, ballX * -1)
elseif ballX > screenW then
offsetX = math.min(screenW * 2, (ballX * -1) + screenW)
end
return offsetX, offsetY
return offsetX * 1.3, offsetY * 1.5
end
-- selene: allow(unscoped_variables)