From d5747d8134b167b7584ffe8fb554699300adc776 Mon Sep 17 00:00:00 2001 From: yaw-man Date: Sat, 14 Jan 2023 09:59:20 -0400 Subject: [PATCH] Smooth trail rendering, for real this time. --- main.lua | 4 ++-- marble.lua | 17 +++++++---------- sitelenpona.lua | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/main.lua b/main.lua index 0d7e1a8..e08262f 100644 --- a/main.lua +++ b/main.lua @@ -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 )]] diff --git a/marble.lua b/marble.lua index 8b28456..659d717 100644 --- a/marble.lua +++ b/marble.lua @@ -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 ) diff --git a/sitelenpona.lua b/sitelenpona.lua index 859dca9..54b4bdd 100644 --- a/sitelenpona.lua +++ b/sitelenpona.lua @@ -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