Smooth trail rendering, for real this time.

This commit is contained in:
yaw-man 2023-01-14 09:59:20 -04:00
parent 5a24ffcd42
commit d5747d8134
3 changed files with 10 additions and 13 deletions

View File

@ -160,11 +160,11 @@ end
function love.draw()
love.graphics.setColor(1.0, 1.0, 1.0)
--[[love.graphics.setColor(1.0, 1.0, 1.0)
love.graphics.print( state.beat.mu or 0, 0)
love.graphics.print( state.beat.t or 0, 0, 10)
love.graphics.print( state.beatScoreThreshold, 0, 20)
love.graphics.print( state.lastBeatScore, 0, 30 )
love.graphics.print( state.lastBeatScore, 0, 30 )]]

View File

@ -26,6 +26,7 @@ end
local function OnImpact( impact )
--Adjust current trajectory according to collision.
if not impact.tNext then return end
return Integrate( impact.tNext - impact.t ) --Hmm! Maybe this should be a fixed step instead for stability's sake.
end
@ -49,18 +50,14 @@ local function OnKey()
end
local function Draw()
love.graphics.print( ddx, 0, 100 )
love.graphics.print( ddy, 0, 110 )
--Extrapolate forward for slightly smoother rendering.
local dt = love.timer.getTime() - curState.t
Integrate( dt + 1 / 60.0 )
local xp, yp = transform:transformPoint( oldState.x, oldState.y )
local xc, yc = transform:transformPoint( curState.x, curState.y )
local xn, yn = transform:transformPoint( newState.x, newState.y )
local dt = love.timer.getTime() - newState.t --Integrate forward for slightly smoother rendering.
local xf, yf = transform:transformPoint(
newState.x + dt * newState.dx,
newState.y + dt * newState.dy )
love.graphics.setCanvas( newBuffer )
love.graphics.setColor( 1.0, 1.0, 1.0 , 0.99 ) -- White.
@ -73,8 +70,8 @@ local function Draw()
love.graphics.setLineJoin( "bevel" )
love.graphics.setLineStyle( "smooth" )
love.graphics.setLineWidth( 8.0 )
love.graphics.line( xp, yp, xc, yc, xn, yn, xf, yf )
love.graphics.circle( "fill", xf, yf, 4.0 )
love.graphics.line( xp, yp, xc, yc, xn, yn)
love.graphics.circle( "fill", xn, yn, 4.0 )
love.graphics.setCanvas( oldBuffer )
love.graphics.clear( 1.0, 1.0, 1.0, 0.0 )

View File

@ -10,7 +10,7 @@ end
sp.Draw = function( str )
local w, h = love.graphics.getDimensions()
local x, y = 0.5 * w - 128, 0.5 * h - 128
love.graphics.setColor( 1.0, 1.0, 1.0, 1.0 )
love.graphics.setColor( 1.0, 1.0, 1.0, 0.5 )
love.graphics.draw( sp[str] or sp.q, x, y )
end