Added menu for browsing recordings.
This commit is contained in:
parent
67dc751cf0
commit
337e0ce154
10
audio.lua
10
audio.lua
|
@ -179,11 +179,11 @@ local function Update( score, level )
|
||||||
|
|
||||||
if level > 2 then
|
if level > 2 then
|
||||||
level = level / 120.0
|
level = level / 120.0
|
||||||
drones.bass:setVolume( 0.7 * (0.2 + math.pow( score, 0.25 )) * level )
|
drones.bass:setVolume( 0.7 * (0.0 + score) * level )
|
||||||
drones.alto:setVolume( 0.3 * (0.3 + math.pow( score, 0.25 )) * level * level)
|
drones.alto:setVolume( 0.3 * (0.3 + score) * level * level)
|
||||||
drones.fuck:setVolume( 4.0 * math.max( 0, level - 0.75 ))
|
drones.fuck:setVolume( 3.0 * (0.2 + score) * math.max( 0, level - 0.75 ))
|
||||||
drones.subs:setVolume( 0.5 * math.max( 0, level - 0.5 ))
|
drones.subs:setVolume( 0.5 * (0.2 + score) * math.max( 0, level - 0.50 ))
|
||||||
drones.wail:setVolume( 2.0 * math.max( 0, level - 0.666 ))
|
drones.wail:setVolume( 1.5 * (0.5 + score) * math.max( 0, level - 0.66 ))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
--UI for selecting a saved game.
|
||||||
|
local love = love
|
||||||
|
local _Update = love.update
|
||||||
|
local _Draw = love.draw
|
||||||
|
local _MousePressed = love.mousepressed
|
||||||
|
local _Resize = love.resize
|
||||||
|
local _KeyPressed = love.keypressed
|
||||||
|
|
||||||
|
local selectedGame = 1
|
||||||
|
local scrollOffset = 1
|
||||||
|
local deleteGame = false
|
||||||
|
local gameList = assert( love.filesystem.getDirectoryItems( "demos" ) )
|
||||||
|
local mouseX, mouseY = 0, 0
|
||||||
|
local w, h = love.graphics.getDimensions()
|
||||||
|
local canvas = love.graphics.newCanvas( w, h * (1 + #gameList) / 10.0 )
|
||||||
|
local font = love.graphics.newFont( 36 )
|
||||||
|
local OnClick
|
||||||
|
|
||||||
|
local function DeleteLeft()
|
||||||
|
return w * 0.75 + 15 + 6
|
||||||
|
end
|
||||||
|
|
||||||
|
local function DeleteRight()
|
||||||
|
return DeleteLeft() + 45
|
||||||
|
end
|
||||||
|
|
||||||
|
local function DrawSelection( )
|
||||||
|
love.graphics.rectangle( "fill", 15, selectedGame * h / 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
local function PopulateGameList()
|
||||||
|
scrollOffset = 0
|
||||||
|
gameList = assert( love.filesystem.getDirectoryItems( "demos" ) )
|
||||||
|
|
||||||
|
love.graphics.setCanvas( canvas )
|
||||||
|
love.graphics.clear()
|
||||||
|
love.graphics.setColor( 0.2, 0.2, 0.2, 0.5 )
|
||||||
|
love.graphics.setLineWidth( 3 )
|
||||||
|
|
||||||
|
for i, name in ipairs( gameList ) do
|
||||||
|
local x, y = 15, i * h / 10
|
||||||
|
|
||||||
|
love.graphics.printf( gameList[i], font, x + 10, y, 0.75 * w, "left" )
|
||||||
|
love.graphics.rectangle( "line", x, y, w * 0.75, h / 10 - 12, 10, 10 )
|
||||||
|
love.graphics.rectangle( "line", DeleteLeft(), y, h / 10 - 12, h / 10 - 12, 10, 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
love.resize = function( newWidth, newHeight )
|
||||||
|
_Resize(newWidth, newHeight )
|
||||||
|
w, h = love.graphics.getDimensions()
|
||||||
|
canvas = love.graphics.newCanvas()
|
||||||
|
return PopulateGameList()
|
||||||
|
end
|
||||||
|
|
||||||
|
love.update = function() end
|
||||||
|
|
||||||
|
love.draw = function()
|
||||||
|
|
||||||
|
love.graphics.draw( canvas, 0, -scrollOffset * h / 10 )
|
||||||
|
love.graphics.setColor( 1.0, 1.0, 1.0, 0.5 )
|
||||||
|
if deleteGame then
|
||||||
|
love.graphics.rectangle( "fill", DeleteLeft(), ( selectedGame - scrollOffset ) * h / 10, h / 10 - 12, h / 10 - 12, 10, 10 )
|
||||||
|
else
|
||||||
|
love.graphics.rectangle( "fill", 15, ( selectedGame - scrollOffset ) * h / 10, w * 0.75, h / 10 - 12, 10, 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
love.graphics.setColor( 1.0, 1.0, 1.0, 1.0 )
|
||||||
|
love.graphics.rectangle( "fill", 0, 0, w, h / 10 - 6 )
|
||||||
|
love.graphics.setColor( 91 / 255, 206 / 255, 250 / 255 )
|
||||||
|
love.graphics.print( "DEMOS "..( gameList[selectedGame] or selectedGame ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
love.mousemoved = function( x, y, dx, dy, istouch)
|
||||||
|
deleteGame = ( x > DeleteLeft() ) and ( x < DeleteRight() )
|
||||||
|
selectedGame = scrollOffset + math.floor( 10 * y / h )
|
||||||
|
end
|
||||||
|
|
||||||
|
love.keypressed = function( key, code, isRepeat )
|
||||||
|
if code == "return" then
|
||||||
|
return OnClick()
|
||||||
|
end
|
||||||
|
|
||||||
|
if code == "down" then
|
||||||
|
|
||||||
|
if selectedGame < #gameList then
|
||||||
|
if selectedGame > 8 then
|
||||||
|
scrollOffset = scrollOffset + 1
|
||||||
|
end
|
||||||
|
selectedGame = selectedGame + 1
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if key == "up" then
|
||||||
|
if selectedGame > 8 then
|
||||||
|
scrollOffset = scrollOffset - 1
|
||||||
|
end
|
||||||
|
if selectedGame > 1 then
|
||||||
|
selectedGame = selectedGame - 1
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if key == "right" or key == "left" then deleteGame = not( deleteGame ) end
|
||||||
|
end
|
||||||
|
|
||||||
|
OnClick = function( x, y, button, istouch, presses )
|
||||||
|
|
||||||
|
if not selectedGame then return end
|
||||||
|
if #gameList < 1 then return end
|
||||||
|
|
||||||
|
if deleteGame then
|
||||||
|
love.filesystem.remove( "demos/"..gameList[selectedGame] )
|
||||||
|
return PopulateGameList()
|
||||||
|
end
|
||||||
|
|
||||||
|
--Restore main state.
|
||||||
|
love.update = _Update
|
||||||
|
love.draw = _Draw
|
||||||
|
love.mousepressed = _MousePressed
|
||||||
|
love.keypressed = _KeyPressed
|
||||||
|
love.resize = _Resize
|
||||||
|
love.mousemoved = nil
|
||||||
|
return "demos/"..gameList[selectedGame]
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
PopulateGameList()
|
||||||
|
|
||||||
|
|
||||||
|
return OnClick
|
67
main.lua
67
main.lua
|
@ -93,36 +93,16 @@ OnImpact = function( impact )
|
||||||
end
|
end
|
||||||
local _OnImpact = OnImpact
|
local _OnImpact = OnImpact
|
||||||
|
|
||||||
local function NewGame( isDemo )
|
local function NewGame( demoName )
|
||||||
love.graphics.setBackgroundColor( 245 / 255, 169 / 255, 184 / 255 ) --Trans pink.
|
love.graphics.setBackgroundColor( 245 / 255, 169 / 255, 184 / 255 ) --Trans pink.
|
||||||
OnImpact = _OnImpact
|
OnImpact = _OnImpact
|
||||||
ExtrapolateBeatScore = _ExtrapolateBeatScore
|
ExtrapolateBeatScore = _ExtrapolateBeatScore
|
||||||
love.draw = Draw
|
love.draw = Draw
|
||||||
love.update = Update
|
love.update = Update
|
||||||
|
|
||||||
|
do --particle shit
|
||||||
particles:reset()
|
particles:reset()
|
||||||
particles:setSizes( 0.0007, 0.0001, 0.0003 )
|
particles:setSizes( 0.0007, 0.0001, 0.0003 )
|
||||||
state.Reset()
|
|
||||||
marble.Reset()
|
|
||||||
wave.Reset()
|
|
||||||
text.Reset()
|
|
||||||
audio.Reset()
|
|
||||||
recorder.Reset()
|
|
||||||
|
|
||||||
state.isDemo = isDemo
|
|
||||||
if isDemo then
|
|
||||||
recorder.Load()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function love.load()
|
|
||||||
UpdateWindowTransform( love.graphics.getDimensions() )
|
|
||||||
|
|
||||||
|
|
||||||
do--particle system setup
|
|
||||||
particles = love.graphics.newParticleSystem(
|
|
||||||
love.graphics.newImage( "prideflag.png" ),
|
|
||||||
1024)
|
|
||||||
|
|
||||||
--particles:setSizes( 0.0007, 0.0001, 0.0003 )
|
--particles:setSizes( 0.0007, 0.0001, 0.0003 )
|
||||||
particles:setSizeVariation( 1 )
|
particles:setSizeVariation( 1 )
|
||||||
particles:setRadialAcceleration( 0, 0.5 )
|
particles:setRadialAcceleration( 0, 0.5 )
|
||||||
|
@ -140,9 +120,33 @@ function love.load()
|
||||||
245 / 255, 169 / 255, 184 / 255, 1,
|
245 / 255, 169 / 255, 184 / 255, 1,
|
||||||
1,1,1,0,
|
1,1,1,0,
|
||||||
245 / 255, 169 / 255, 184 / 255, 1,
|
245 / 255, 169 / 255, 184 / 255, 1,
|
||||||
1,1,1,0
|
1,1,1,0)
|
||||||
|
end
|
||||||
|
state.Reset()
|
||||||
|
marble.Reset()
|
||||||
|
wave.Reset()
|
||||||
|
text.Reset()
|
||||||
|
audio.Reset()
|
||||||
|
recorder.Reset()
|
||||||
|
|
||||||
|
state.isDemo = demoName
|
||||||
|
if demoName then
|
||||||
|
recorder.Load( demoName )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.load()
|
||||||
|
UpdateWindowTransform( love.graphics.getDimensions() )
|
||||||
|
|
||||||
|
|
||||||
|
do--particle system setup
|
||||||
|
particles = love.graphics.newParticleSystem(
|
||||||
|
love.graphics.newImage( "prideflag.png" ),
|
||||||
|
2048)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +162,7 @@ function love.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
ExtrapolateBeatScore = function( )
|
ExtrapolateBeatScore = function( )
|
||||||
local t = love.timer.getTime()
|
local t = state.tick / 120.0
|
||||||
local beat = state.beat
|
local beat = state.beat
|
||||||
if not beat.t then return 2.0 end
|
if not beat.t then return 2.0 end
|
||||||
if not beat.mu then return 2.0 end
|
if not beat.mu then return 2.0 end
|
||||||
|
@ -341,11 +345,18 @@ Update = function( dt )
|
||||||
end
|
end
|
||||||
_Update = Update
|
_Update = Update
|
||||||
|
|
||||||
|
local function LoadGame() -- Load game screen.
|
||||||
|
local loadGame = assert( dofile "loadgame.lua" )
|
||||||
|
love.mousepressed = function( x, y, button, istouch, presses)
|
||||||
|
local demoName = loadGame( x, y, button, istouch, presses )
|
||||||
|
if demoName then return NewGame( demoName ) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function love.keypressed( key, code, isRepeat )
|
function love.keypressed( key, code, isRepeat )
|
||||||
if key == "escape" then return love.event.quit() end
|
if key == "escape" then return love.event.quit() end
|
||||||
if key == "space" then return NewGame() end
|
if key == "space" then return NewGame() end
|
||||||
if code == "return" then return NewGame( true ) end --Play demo.
|
if code == "return" then return LoadGame() end --Play demo.
|
||||||
if code == "q" then recorder.Save() end
|
|
||||||
if state.isDemo then return end
|
if state.isDemo then return end
|
||||||
return marble.OnKey( state.tick )
|
return marble.OnKey( state.tick )
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,7 +125,7 @@ function marble.Draw()
|
||||||
|
|
||||||
--Extrapolate forward for slightly smoother rendering.
|
--Extrapolate forward for slightly smoother rendering.
|
||||||
local dt = love.timer.getTime() - curState.t
|
local dt = love.timer.getTime() - curState.t
|
||||||
marble.Integrate( 1 / 120.0 )
|
marble.Integrate( 2 / 120.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 )
|
||||||
|
|
|
@ -20,8 +20,9 @@ function recorder.Update( ddx, ddy )
|
||||||
recorder[i] = string.char( byte + 48 )
|
recorder[i] = string.char( byte + 48 )
|
||||||
end
|
end
|
||||||
|
|
||||||
function recorder.Load( )
|
function recorder.Load( filename )
|
||||||
local s = love.filesystem.read( "demo" )
|
local s = love.filesystem.read( filename )
|
||||||
|
print( filename )
|
||||||
if not s then return end
|
if not s then return end
|
||||||
local j = 1
|
local j = 1
|
||||||
for c in s:gmatch( "." ) do
|
for c in s:gmatch( "." ) do
|
||||||
|
@ -54,7 +55,7 @@ function recorder.NextTick( )
|
||||||
end
|
end
|
||||||
|
|
||||||
function recorder.Save( )
|
function recorder.Save( )
|
||||||
return assert( love.filesystem.write( "demo", table.concat( recorder, "", 1, i ) ) )
|
return assert( love.filesystem.write( "demos/"..os.time()..".yod" , table.concat( recorder ) ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
return recorder
|
return recorder
|
4
wave.lua
4
wave.lua
|
@ -47,9 +47,9 @@ local shader = love.graphics.newShader([[
|
||||||
p.y = -p.y;
|
p.y = -p.y;
|
||||||
|
|
||||||
float r = r( atan(p.y, p.x) ) - length( p );
|
float r = r( atan(p.y, p.x) ) - length( p );
|
||||||
float q = float( r < 0.05 ) * clamp( 0.5 - score, 0.0, 1.0 ) ;
|
float q = float( r < 0.05 ) * clamp( 1.0 - score, 0.0, 1.0 ) ;
|
||||||
|
|
||||||
return vec4( q + (1.0 + clamp( score, 0.0, 1.0 ) * r * r * 0.2) * color.xyz, float(r > 0.0) ) ;
|
return vec4( q + (1.0 + clamp( score, 0.0, 1.0 ) * r * r * 0.5) * color.xyz, float(r > 0.0) ) ;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue