Correct draw offset for hits to right field.
This commit is contained in:
parent
6dd8469409
commit
6308871692
|
@ -1,5 +1,3 @@
|
||||||
local ballBuffer <const> = 5
|
|
||||||
|
|
||||||
--- Assumes that background image is of size
|
--- Assumes that background image is of size
|
||||||
--- XXX
|
--- XXX
|
||||||
--- XOX
|
--- XOX
|
||||||
|
@ -9,19 +7,17 @@ function getDrawOffset(screenW, screenH, ballX, ballY)
|
||||||
if ballY > screenH then
|
if ballY > screenH then
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end
|
end
|
||||||
if ballY < ballBuffer then
|
offsetY = math.max(0, -1 * ballY)
|
||||||
offsetY = math.max(ballBuffer, -1 * (ballY - ballBuffer))
|
|
||||||
else
|
if ballX > 0 and ballX < screenW then
|
||||||
offsetY = 0
|
|
||||||
end
|
|
||||||
if ballX > 0 and ballX < (screenW - ballBuffer) then
|
|
||||||
offsetX = 0
|
offsetX = 0
|
||||||
elseif ballX < ballBuffer then
|
elseif ballX < 0 then
|
||||||
offsetX = math.max(-1 * screenW, -1 * (ballX - ballBuffer))
|
offsetX = math.max(-1 * screenW, ballX * -1)
|
||||||
elseif ballX > (screenW - ballBuffer) then
|
elseif ballX > screenW then
|
||||||
offsetX = math.min(screenW * 2, -1 * (ballX - ballBuffer))
|
offsetX = math.min(screenW * 2, (ballX * -1) + screenW)
|
||||||
end
|
end
|
||||||
return offsetX, offsetY
|
|
||||||
|
return offsetX * 1.3, offsetY * 1.5
|
||||||
end
|
end
|
||||||
|
|
||||||
-- selene: allow(unscoped_variables)
|
-- selene: allow(unscoped_variables)
|
||||||
|
|
Loading…
Reference in New Issue