Smooth trail rendering, for real this time.
This commit is contained in:
parent
5a24ffcd42
commit
d5747d8134
4
main.lua
4
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 )]]
|
||||
|
||||
|
||||
|
||||
|
|
15
marble.lua
15
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
|
||||
|
||||
|
@ -50,18 +51,14 @@ 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.
|
||||
love.graphics.draw( oldBuffer ) --Time-dependent fade: overlay canvas over itself.
|
||||
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue