Persistence of continuous accelerations.
This commit is contained in:
parent
7a1533a6a7
commit
e1e00dce4c
1
conf.lua
1
conf.lua
|
@ -1,6 +1,7 @@
|
|||
function love.conf( t )
|
||||
t.version = "11.4"
|
||||
t.identity = "Your Own Drum"
|
||||
t.console = true
|
||||
|
||||
t.modules.joystick = false
|
||||
t.modules.physics = false
|
||||
|
|
39
recorder.lua
39
recorder.lua
|
@ -2,6 +2,7 @@
|
|||
local love = love
|
||||
local recorder = {}
|
||||
recorder.isLoaded = false
|
||||
local ddxs, ddys
|
||||
local i = 0
|
||||
|
||||
function recorder.Reset()
|
||||
|
@ -9,15 +10,12 @@ function recorder.Reset()
|
|||
for k, _ in ipairs( recorder ) do recorder[k] = nil end
|
||||
end
|
||||
|
||||
function recorder.UpdateCts( ddx, ddy )
|
||||
local xByte = 0
|
||||
local yByte = 0
|
||||
|
||||
--i = i + 1
|
||||
recorder[i] = love.data.pack( "data", "dd", ddx, ddy )
|
||||
function recorder.Update( ddx, ddy )
|
||||
i = i + 1
|
||||
recorder[i] = love.data.pack( "string", "!16<dd", ddx, ddy )
|
||||
end
|
||||
|
||||
function recorder.Update( ddx, ddy )
|
||||
--[[function recorder.Update( ddx, ddy )
|
||||
local byte = 0
|
||||
if ddx > 0.5 then byte = byte + 1 end
|
||||
if ddy > 0.5 then byte = byte + 2 end
|
||||
|
@ -26,15 +24,16 @@ function recorder.Update( ddx, ddy )
|
|||
|
||||
i = i + 1
|
||||
recorder[i] = string.char( byte + 48 )
|
||||
end
|
||||
end]]
|
||||
|
||||
function recorder.Load( filename )
|
||||
ddxs, ddys = {}, {}
|
||||
local s = love.filesystem.read( filename )
|
||||
print( filename )
|
||||
if not s then return end
|
||||
local j = 1
|
||||
for c in s:gmatch( "." ) do
|
||||
recorder[j] = string.byte( c ) - 48
|
||||
local k, j = 1, 1
|
||||
local n = s:len()
|
||||
while k < n do
|
||||
ddxs[j], ddys[j], k = love.data.unpack( "!16<dd", s, k)
|
||||
j = j + 1
|
||||
end
|
||||
recorder.isLoaded = true
|
||||
|
@ -44,22 +43,8 @@ function recorder.Load( filename )
|
|||
end
|
||||
|
||||
function recorder.NextTick( )
|
||||
|
||||
local byte = recorder[ i + 1 ]
|
||||
if not byte then return end
|
||||
i = i + 1
|
||||
|
||||
local a, b, c, d =
|
||||
math.floor( byte ) % 2,
|
||||
math.floor( byte / 2 ) % 2,
|
||||
math.floor( byte / 4 ) % 2,
|
||||
math.floor( byte / 8 ) % 2
|
||||
|
||||
local ddx, ddy = a - c, b - d
|
||||
local n = math.sqrt( ddx * ddx + ddy * ddy )
|
||||
if n < 0.001 then return 0, 0 end
|
||||
ddx, ddy = ddx / n, ddy / n
|
||||
return ddx, ddy
|
||||
return ddxs[i], ddys[i]
|
||||
end
|
||||
|
||||
function recorder.Save( )
|
||||
|
|
Loading…
Reference in New Issue