fix: yield inside wedge rasteriser and between wedges; only redraw ball each spin frame
This commit is contained in:
@@ -181,8 +181,12 @@ local function drawWedge(slotIdx, rotorAngle, glowing)
|
||||
local by1 = math.ceil(CY + ro) + 1
|
||||
|
||||
-- Normalise angle range to handle wrap-around
|
||||
-- We scan row by row and fill runs for speed
|
||||
-- We scan row by row and fill runs for speed.
|
||||
-- Yield every 32 rows so CC:Tweaked doesn't kill us.
|
||||
local rowCount = 0
|
||||
for sy = by0, by1 do
|
||||
rowCount = rowCount + 1
|
||||
if rowCount % 32 == 0 then sleep(0) end
|
||||
local runStart = nil
|
||||
for sx = bx0, bx1 do
|
||||
local dx = sx - CX
|
||||
@@ -228,6 +232,8 @@ end
|
||||
local function drawAllWedges(rotorAngle, glowSlot)
|
||||
for i = 1, NUM_POCKETS do
|
||||
drawWedge(i, rotorAngle, i == glowSlot)
|
||||
-- yield between wedges so CC doesn't kill us during init
|
||||
sleep(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -360,10 +366,10 @@ local function spin()
|
||||
ballR = (R_OUTER - 6 + R_POCKET_OUT + 2) / 2 * (1 - t) + R_SETTLE * t
|
||||
end
|
||||
|
||||
-- Draw frame
|
||||
drawWheelStatic(rotorAngle, nil)
|
||||
|
||||
-- Erase old ball area by redrawing wheel under it (handled by full redraw above)
|
||||
-- Erase old ball, draw new ball.
|
||||
-- Repaint a small circle at the old position with the track colour,
|
||||
-- then draw the ball at the new position.
|
||||
px_circle(ballX, ballY, BALL_RADIUS + 3, COL_TRACK)
|
||||
local bx, by = ballPosAt(ballR, ballAngle)
|
||||
drawBallAt(bx, by)
|
||||
gpu.sync()
|
||||
@@ -407,17 +413,17 @@ end
|
||||
----------------------------------------------------------------------
|
||||
|
||||
local function glowAnimation(slotIdx)
|
||||
local R_SETTLE = (R_POCKET_IN + R_POCKET_OUT) / 2
|
||||
local sa = slotAngle(slotIdx, rotorAngle)
|
||||
local bx, by = ballPosAt(R_SETTLE, sa)
|
||||
for flash = 1, 6 do
|
||||
drawWheelStatic(rotorAngle, flash % 2 == 1 and slotIdx or nil)
|
||||
local sa = slotAngle(slotIdx, rotorAngle)
|
||||
local bx, by = ballPosAt((R_POCKET_IN + R_POCKET_OUT) / 2, sa)
|
||||
drawWedge(slotIdx, rotorAngle, flash % 2 == 1)
|
||||
drawBallAt(bx, by)
|
||||
gpu.sync()
|
||||
sleep(0.18)
|
||||
end
|
||||
drawWheelStatic(rotorAngle, slotIdx)
|
||||
local sa = slotAngle(slotIdx, rotorAngle)
|
||||
local bx, by = ballPosAt((R_POCKET_IN + R_POCKET_OUT) / 2, sa)
|
||||
-- Leave glowing
|
||||
drawWedge(slotIdx, rotorAngle, true)
|
||||
drawBallAt(bx, by)
|
||||
gpu.sync()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user