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()
|
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.mu or 0, 0)
|
||||||
love.graphics.print( state.beat.t or 0, 0, 10)
|
love.graphics.print( state.beat.t or 0, 0, 10)
|
||||||
love.graphics.print( state.beatScoreThreshold, 0, 20)
|
love.graphics.print( state.beatScoreThreshold, 0, 20)
|
||||||
love.graphics.print( state.lastBeatScore, 0, 30 )
|
love.graphics.print( state.lastBeatScore, 0, 30 )]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
17
marble.lua
17
marble.lua
|
@ -26,6 +26,7 @@ end
|
||||||
|
|
||||||
local function OnImpact( impact )
|
local function OnImpact( impact )
|
||||||
--Adjust current trajectory according to collision.
|
--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.
|
return Integrate( impact.tNext - impact.t ) --Hmm! Maybe this should be a fixed step instead for stability's sake.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,18 +50,14 @@ local function OnKey()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Draw()
|
local function Draw()
|
||||||
|
|
||||||
love.graphics.print( ddx, 0, 100 )
|
--Extrapolate forward for slightly smoother rendering.
|
||||||
love.graphics.print( ddy, 0, 110 )
|
local dt = love.timer.getTime() - curState.t
|
||||||
|
Integrate( dt + 1 / 60.0 )
|
||||||
|
|
||||||
local xp, yp = transform:transformPoint( oldState.x, oldState.y )
|
local xp, yp = transform:transformPoint( oldState.x, oldState.y )
|
||||||
local xc, yc = transform:transformPoint( curState.x, curState.y )
|
local xc, yc = transform:transformPoint( curState.x, curState.y )
|
||||||
local xn, yn = transform:transformPoint( newState.x, newState.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.setCanvas( newBuffer )
|
||||||
love.graphics.setColor( 1.0, 1.0, 1.0 , 0.99 ) -- White.
|
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.setLineJoin( "bevel" )
|
||||||
love.graphics.setLineStyle( "smooth" )
|
love.graphics.setLineStyle( "smooth" )
|
||||||
love.graphics.setLineWidth( 8.0 )
|
love.graphics.setLineWidth( 8.0 )
|
||||||
love.graphics.line( xp, yp, xc, yc, xn, yn, xf, yf )
|
love.graphics.line( xp, yp, xc, yc, xn, yn)
|
||||||
love.graphics.circle( "fill", xf, yf, 4.0 )
|
love.graphics.circle( "fill", xn, yn, 4.0 )
|
||||||
|
|
||||||
love.graphics.setCanvas( oldBuffer )
|
love.graphics.setCanvas( oldBuffer )
|
||||||
love.graphics.clear( 1.0, 1.0, 1.0, 0.0 )
|
love.graphics.clear( 1.0, 1.0, 1.0, 0.0 )
|
||||||
|
|
|
@ -10,7 +10,7 @@ end
|
||||||
sp.Draw = function( str )
|
sp.Draw = function( str )
|
||||||
local w, h = love.graphics.getDimensions()
|
local w, h = love.graphics.getDimensions()
|
||||||
local x, y = 0.5 * w - 128, 0.5 * h - 128
|
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 )
|
love.graphics.draw( sp[str] or sp.q, x, y )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue