Final commit before post-jam release, "1.0.0"?
New features since last release: - Display score breakdown, high score, and letter grades. - Options menu with volume control, keybindings, and true fullscreen. - Demos menu. View saved games! - Mouse controls, sorta. Mouse controlled menus! - High contrast mode. - Instructions displayed on startup. - Default demo ships with game. - Render sitelen pona quote symbols to and te - Beat combo indicator. Outstanding defects: - Options menu not persistent. - Mouse controls feel like complete dogshit.
This commit is contained in:
parent
e1e00dce4c
commit
5dfd415d3b
1
conf.lua
1
conf.lua
|
@ -1,7 +1,6 @@
|
||||||
function love.conf( t )
|
function love.conf( t )
|
||||||
t.version = "11.4"
|
t.version = "11.4"
|
||||||
t.identity = "Your Own Drum"
|
t.identity = "Your Own Drum"
|
||||||
t.console = true
|
|
||||||
|
|
||||||
t.modules.joystick = false
|
t.modules.joystick = false
|
||||||
t.modules.physics = false
|
t.modules.physics = false
|
||||||
|
|
Binary file not shown.
31
loadgame.lua
31
loadgame.lua
|
@ -1,17 +1,18 @@
|
||||||
--UI for selecting a saved game.
|
--UI for selecting a saved game.
|
||||||
local love = love
|
local love = love
|
||||||
local loadGame = {}
|
local loadGame = {}
|
||||||
local _Update = love.update
|
local _Update
|
||||||
local _Draw = love.draw
|
local _Draw
|
||||||
local _MousePressed = love.mousepressed
|
local _MousePressed
|
||||||
local _Resize = love.resize
|
local _MouseMoved
|
||||||
local _KeyPressed = love.keypressed
|
local _Resize
|
||||||
love.mouse.setRelativeMode( false )
|
local _KeyPressed
|
||||||
|
|
||||||
local function RestoreMainState()
|
local function RestoreMainState()
|
||||||
love.update = _Update
|
love.update = _Update
|
||||||
love.draw = _Draw
|
love.draw = _Draw
|
||||||
love.mousepressed = _MousePressed
|
love.mousepressed = _MousePressed
|
||||||
|
love.mousemoved = _MouseMoved
|
||||||
love.keypressed = _KeyPressed
|
love.keypressed = _KeyPressed
|
||||||
love.resize = _Resize
|
love.resize = _Resize
|
||||||
love.mousemoved = nil
|
love.mousemoved = nil
|
||||||
|
@ -32,7 +33,7 @@ local OnClick
|
||||||
|
|
||||||
|
|
||||||
local function DeleteLeft()
|
local function DeleteLeft()
|
||||||
return w * 0.75 + 15 + 6
|
return love.graphics.getWidth() * 0.75 + 15 + 6
|
||||||
end
|
end
|
||||||
|
|
||||||
local function DeleteRight()
|
local function DeleteRight()
|
||||||
|
@ -47,6 +48,8 @@ local function PopulateGameList()
|
||||||
scrollOffset = 0
|
scrollOffset = 0
|
||||||
gameList = assert( love.filesystem.getDirectoryItems( "demos" ) )
|
gameList = assert( love.filesystem.getDirectoryItems( "demos" ) )
|
||||||
|
|
||||||
|
local w, h = love.graphics.getDimensions()
|
||||||
|
|
||||||
canvas = love.graphics.newCanvas( w, h * (1 + #gameList) / 10.0 )
|
canvas = love.graphics.newCanvas( w, h * (1 + #gameList) / 10.0 )
|
||||||
love.graphics.setCanvas( canvas )
|
love.graphics.setCanvas( canvas )
|
||||||
love.graphics.clear()
|
love.graphics.clear()
|
||||||
|
@ -74,7 +77,11 @@ end
|
||||||
local updateLoadMenu = function() end
|
local updateLoadMenu = function() end
|
||||||
|
|
||||||
local drawLoadGameMenu = function()
|
local drawLoadGameMenu = function()
|
||||||
|
local w, h = love.graphics.getDimensions()
|
||||||
love.graphics.setColor( 1, 1, 1, 1 )
|
love.graphics.setColor( 1, 1, 1, 1 )
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0,0,0, 1 )
|
||||||
|
end
|
||||||
love.graphics.draw( canvas, 0, 15 - scrollOffset * h / 10 )
|
love.graphics.draw( canvas, 0, 15 - scrollOffset * h / 10 )
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,10 +163,18 @@ end
|
||||||
|
|
||||||
|
|
||||||
local wheelMoved = function(x, y)
|
local wheelMoved = function(x, y)
|
||||||
scrollOffset = math.max( 0, math.min( #gameList, scrollOffset - y * 0.1 ) )
|
--scrollOffset = math.max( 0, math.min( #gameList, scrollOffset - y * 0.1 ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function LoadGameMenu()
|
local function LoadGameMenu()
|
||||||
|
_Update = love.update
|
||||||
|
_Draw = love.draw
|
||||||
|
_MousePressed = love.mousepressed
|
||||||
|
_MouseMoved = love.mousemoved
|
||||||
|
_Resize = love.resize
|
||||||
|
_KeyPressed = love.keypressed
|
||||||
|
love.mouse.setRelativeMode( false )
|
||||||
|
|
||||||
love.wheelmoved = wheelMoved
|
love.wheelmoved = wheelMoved
|
||||||
love.mousemoved = mouseMoved
|
love.mousemoved = mouseMoved
|
||||||
love.draw = drawLoadGameMenu
|
love.draw = drawLoadGameMenu
|
||||||
|
|
17
main.lua
17
main.lua
|
@ -160,6 +160,7 @@ function love.load()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
loadGame = assert( require "loadgame" )
|
||||||
options = assert( require( "options" ) )
|
options = assert( require( "options" ) )
|
||||||
mouseControl = assert( require "mousecontrols" )
|
mouseControl = assert( require "mousecontrols" )
|
||||||
sitelenpona = assert( require "sitelenpona" )
|
sitelenpona = assert( require "sitelenpona" )
|
||||||
|
@ -231,7 +232,7 @@ OnVictory = function()
|
||||||
state.isDemo = false
|
state.isDemo = false
|
||||||
else
|
else
|
||||||
scores.Save()
|
scores.Save()
|
||||||
recorder.Save()
|
recorder.Save( scores.Get(), state.tick)
|
||||||
end
|
end
|
||||||
|
|
||||||
particles:setParticleLifetime( 0, 30 )
|
particles:setParticleLifetime( 0, 30 )
|
||||||
|
@ -262,6 +263,7 @@ OnVictory = function()
|
||||||
marble.Update()
|
marble.Update()
|
||||||
wave.Update()
|
wave.Update()
|
||||||
|
|
||||||
|
|
||||||
dt = dt - step
|
dt = dt - step
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -332,6 +334,11 @@ Update = function( dt )
|
||||||
|
|
||||||
state.tick = state.tick + 1
|
state.tick = state.tick + 1
|
||||||
|
|
||||||
|
if mouseControl.isActive then
|
||||||
|
mouseControl.update()
|
||||||
|
marble.SetAcceleration( mouseControl.getAcceleration() )
|
||||||
|
end
|
||||||
|
|
||||||
if state.isDemo then
|
if state.isDemo then
|
||||||
local ddx, ddy = recorder.NextTick()
|
local ddx, ddy = recorder.NextTick()
|
||||||
if ddx then marble.SetAcceleration( ddx, ddy )
|
if ddx then marble.SetAcceleration( ddx, ddy )
|
||||||
|
@ -363,8 +370,10 @@ local function OptionsMenu()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function LoadGame() -- Load game screen.
|
local function LoadGame() -- Load game screen.
|
||||||
if not loadGame then loadGame = assert( require "loadgame" ) end
|
|
||||||
local Click, Press = assert(loadGame.OnClick), assert(loadGame.KeyPress)
|
local Click, Press = assert(loadGame.OnClick), assert(loadGame.KeyPress)
|
||||||
|
loadGame.LoadGameMenu()
|
||||||
|
|
||||||
love.mousepressed = function( x, y, button, istouch, presses)
|
love.mousepressed = function( x, y, button, istouch, presses)
|
||||||
local demoName = Click( x, y, button, istouch, presses )
|
local demoName = Click( x, y, button, istouch, presses )
|
||||||
if demoName then return NewGame( demoName ) end
|
if demoName then return NewGame( demoName ) end
|
||||||
|
@ -375,7 +384,7 @@ local function LoadGame() -- Load game screen.
|
||||||
if demoName then return NewGame( demoName ) end
|
if demoName then return NewGame( demoName ) end
|
||||||
end
|
end
|
||||||
|
|
||||||
loadGame.LoadGameMenu()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed( key, code, isRepeat )
|
function love.keypressed( key, code, isRepeat )
|
||||||
|
@ -385,6 +394,7 @@ function love.keypressed( key, code, isRepeat )
|
||||||
if code == "o" then return OptionsMenu() end
|
if code == "o" then return OptionsMenu() end
|
||||||
if state.isDemo then return end
|
if state.isDemo then return end
|
||||||
|
|
||||||
|
mouseControl.isActive = false
|
||||||
return marble.OnKey(
|
return marble.OnKey(
|
||||||
love.keyboard.isScancodeDown( options.up.value ),
|
love.keyboard.isScancodeDown( options.up.value ),
|
||||||
love.keyboard.isScancodeDown( options.left.value ),
|
love.keyboard.isScancodeDown( options.left.value ),
|
||||||
|
@ -408,6 +418,7 @@ end
|
||||||
|
|
||||||
--TODO: make this feel better.
|
--TODO: make this feel better.
|
||||||
function love.mousemoved( x, y, dx, dy, number, istouch )
|
function love.mousemoved( x, y, dx, dy, number, istouch )
|
||||||
|
mouseControl.isActive = true
|
||||||
dx, dy = mouseControl.mousemoved( dx, dy )
|
dx, dy = mouseControl.mousemoved( dx, dy )
|
||||||
if dx then return marble.SetAcceleration( dx, dy ) end
|
if dx then return marble.SetAcceleration( dx, dy ) end
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,6 +84,9 @@ function marble.Update()
|
||||||
oldState[k] = curState[k]
|
oldState[k] = curState[k]
|
||||||
curState[k] = newState[k]
|
curState[k] = newState[k]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Inertia.
|
||||||
|
--ddx, ddy = ddx * 0.95, ddy * 0.95
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,37 @@
|
||||||
local mouseControl = {}
|
local mouseControl = { isActive = false }
|
||||||
local love = love
|
local love = love
|
||||||
|
|
||||||
local t = love.timer.getTime()
|
local x, y = 0, 0
|
||||||
|
|
||||||
|
local DECAY = 0.8
|
||||||
|
local SENSITIVITY = 0.8
|
||||||
|
|
||||||
function mouseControl.Reset()
|
function mouseControl.Reset()
|
||||||
t = love.timer.getTime()
|
x, y = 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function mouseControl.mousemoved( dx, dy )
|
function mouseControl.mousemoved( dx, dy )
|
||||||
local dt = love.timer.getTime()
|
|
||||||
if dt - t < 1 / 1000.0 then return end
|
|
||||||
dt, t = dt - t, dt
|
|
||||||
|
|
||||||
dx, dy = dx * dt, -dy * dt
|
dx, dy = SENSITIVITY * dx, SENSITIVITY * dy
|
||||||
|
dx, dy = dx * dx * dx , dy * dy * dy
|
||||||
|
x, y = dx + x, y - dy
|
||||||
|
|
||||||
local norm = math.sqrt( dx * dx + dy * dy )
|
|
||||||
if norm > 1 then dx, dy = dx / norm, dy / norm end
|
|
||||||
|
|
||||||
if norm < 0.01 then return 0, 0 end
|
return mouseControl.getAcceleration()
|
||||||
return dx, dy
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mouseControl.update()
|
||||||
|
local norm = math.sqrt( x * x + y * y )
|
||||||
|
local decay = DECAY * norm / ( norm + 1 )
|
||||||
|
x, y = decay * x, decay * y
|
||||||
|
end
|
||||||
|
|
||||||
|
function mouseControl.getAcceleration()
|
||||||
|
local norm = math.sqrt( x * x + y * y )
|
||||||
|
if norm > 1 then return x / norm, y / norm end
|
||||||
|
if norm < 0.001 then return 0, 0 end
|
||||||
|
return x, y
|
||||||
|
end
|
||||||
|
|
||||||
return mouseControl
|
return mouseControl
|
69
options.lua
69
options.lua
|
@ -16,22 +16,31 @@ if not options.initialized then
|
||||||
options.initialized = true
|
options.initialized = true
|
||||||
|
|
||||||
local keyBindCallback = function(self, code)
|
local keyBindCallback = function(self, code)
|
||||||
self.value = code
|
self.value = code or self.value
|
||||||
end
|
end
|
||||||
|
|
||||||
options.optionValues = {
|
options.optionValues = {
|
||||||
{ name = "options",
|
{ name = "options",
|
||||||
value = "back",
|
value = "",
|
||||||
callback = function(self)
|
callback = function(self)
|
||||||
return ExitMenu()
|
end
|
||||||
|
},
|
||||||
|
|
||||||
|
{ name = "fullscreen",
|
||||||
|
value = false,
|
||||||
|
callback = function(self)
|
||||||
|
self.value = not(self.value)
|
||||||
|
love.window.setFullscreen( self.value )
|
||||||
|
love.event.push( "resize", love.graphics.getWidth(), love.graphics.getHeight() )
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
{ name = "high contrast",
|
{ name = "high contrast",
|
||||||
value = false,
|
value = false,
|
||||||
callback = function(self, code)
|
callback = function(self, code)
|
||||||
if code == "return" or code == "backspace" then return end
|
if code == "backspace" then return end
|
||||||
self.value = not( self.value )
|
self.value = not( self.value )
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -43,8 +52,9 @@ if not options.initialized then
|
||||||
if (code == "left" or code == "a") then isIncreasing = -1
|
if (code == "left" or code == "a") then isIncreasing = -1
|
||||||
elseif (code == "right" or code == "d") then isIncreasing = 1
|
elseif (code == "right" or code == "d") then isIncreasing = 1
|
||||||
else return false end
|
else return false end
|
||||||
self.value = math.max( 0, math.min( 1,
|
self.value = math.max( 0, math.min( 2,
|
||||||
self.value + (isIncreasing * 0.05 )))
|
self.value + (isIncreasing * 0.05 )))
|
||||||
|
love.audio.setVolume( self.value )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,6 +95,9 @@ local isAwaitingKey = false
|
||||||
local font = love.graphics.newFont( 32 )
|
local font = love.graphics.newFont( 32 )
|
||||||
local function Draw()
|
local function Draw()
|
||||||
love.graphics.setColor( 1,1,1,1 )
|
love.graphics.setColor( 1,1,1,1 )
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0, 1 )
|
||||||
|
end
|
||||||
for i, option in ipairs( options.optionValues ) do
|
for i, option in ipairs( options.optionValues ) do
|
||||||
love.graphics.printf( option.name, font, 100, i * 50, 1000, "left")
|
love.graphics.printf( option.name, font, 100, i * 50, 1000, "left")
|
||||||
love.graphics.printf( tostring( option.value ), font, -100, i * 50, love.graphics.getWidth(), "right")
|
love.graphics.printf( tostring( option.value ), font, -100, i * 50, love.graphics.getWidth(), "right")
|
||||||
|
@ -113,21 +126,53 @@ local function SelectPreviousOption()
|
||||||
option = options.optionValues[ optionIdx]
|
option = options.optionValues[ optionIdx]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function MouseMoved( x, y )
|
||||||
|
optionIdx =
|
||||||
|
math.min( #options.optionValues,
|
||||||
|
math.max( 1,
|
||||||
|
math.floor( y / 50 )
|
||||||
|
))
|
||||||
|
option = options.optionValues[ optionIdx]
|
||||||
|
|
||||||
|
if ( x > love.graphics.getWidth() - 200 ) then
|
||||||
|
isAwaitingKey = true
|
||||||
|
else
|
||||||
|
isAwaitingKey = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function KeyPress(key, code, isRepeat)
|
local function KeyPress(key, code, isRepeat)
|
||||||
|
|
||||||
if code == "backspace" then return ExitMenu() end
|
if not( isAwaitingKey ) then
|
||||||
if isAwaitingKey then
|
|
||||||
|
|
||||||
|
if code == "backspace" then
|
||||||
|
return ExitMenu() end
|
||||||
|
if optionIdx and
|
||||||
|
code == "return" or
|
||||||
|
code == "right" then
|
||||||
|
isAwaitingKey = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if code == "down" then return SelectNextOption() end
|
||||||
|
if code == "up" then return SelectPreviousOption() end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if code == "backspace" then isAwaitingKey = false end
|
||||||
if code == "escape" then return end
|
if code == "escape" then return end
|
||||||
isAwaitingKey = (options.optionValues[optionIdx]):callback( code )
|
isAwaitingKey = (options.optionValues[optionIdx]):callback( code )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if code == "return" and optionIdx then isAwaitingKey = true; return end
|
|
||||||
if code == "down" then return SelectNextOption() end
|
end
|
||||||
if code == "up" then return SelectPreviousOption() end
|
|
||||||
|
|
||||||
|
local function MousePressed( )
|
||||||
|
return KeyPress( )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EnterMenu()
|
local function EnterMenu()
|
||||||
|
@ -136,13 +181,17 @@ local function EnterMenu()
|
||||||
mousepressed = love.mousepressed
|
mousepressed = love.mousepressed
|
||||||
keypressed = love.keypressed
|
keypressed = love.keypressed
|
||||||
mousemoved = love.mousemoved
|
mousemoved = love.mousemoved
|
||||||
|
love.mouse.setRelativeMode( false )
|
||||||
|
|
||||||
love.draw = Draw
|
love.draw = Draw
|
||||||
love.keypressed = KeyPress
|
love.keypressed = KeyPress
|
||||||
love.update = function() end
|
love.update = function() end
|
||||||
|
love.mousemoved = MouseMoved
|
||||||
|
love.mousepressed = MousePressed
|
||||||
end
|
end
|
||||||
|
|
||||||
function ExitMenu()
|
function ExitMenu()
|
||||||
|
love.mouse.setRelativeMode( true )
|
||||||
love.mousemoved = mousemoved
|
love.mousemoved = mousemoved
|
||||||
love.keypressed = keypressed
|
love.keypressed = keypressed
|
||||||
love.mousepressed = mousepressed
|
love.mousepressed = mousepressed
|
||||||
|
|
|
@ -6,7 +6,7 @@ local ddxs, ddys
|
||||||
local i = 0
|
local i = 0
|
||||||
|
|
||||||
function recorder.Reset()
|
function recorder.Reset()
|
||||||
i = 0
|
i = 1
|
||||||
for k, _ in ipairs( recorder ) do recorder[k] = nil end
|
for k, _ in ipairs( recorder ) do recorder[k] = nil end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ function recorder.Load( filename )
|
||||||
ddxs, ddys = {}, {}
|
ddxs, ddys = {}, {}
|
||||||
local s = love.filesystem.read( filename )
|
local s = love.filesystem.read( filename )
|
||||||
if not s then return end
|
if not s then return end
|
||||||
local k, j = 1, 1
|
local j = 1
|
||||||
|
local score, ticks, k = love.data.unpack( "!16<dJ", s, 1)
|
||||||
local n = s:len()
|
local n = s:len()
|
||||||
while k < n do
|
while k < n do
|
||||||
ddxs[j], ddys[j], k = love.data.unpack( "!16<dd", s, k)
|
ddxs[j], ddys[j], k = love.data.unpack( "!16<dd", s, k)
|
||||||
|
@ -47,7 +48,8 @@ function recorder.NextTick( )
|
||||||
return ddxs[i], ddys[i]
|
return ddxs[i], ddys[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
function recorder.Save( )
|
function recorder.Save( score, ticks )
|
||||||
|
recorder[1] = love.data.pack( "string", "!16<dJ", score, ticks )
|
||||||
if not love.filesystem.getInfo( "demos" ) then love.filesystem.createDirectory( "demos" ) end
|
if not love.filesystem.getInfo( "demos" ) then love.filesystem.createDirectory( "demos" ) end
|
||||||
return assert( love.filesystem.write( "demos/"..os.time()..".yod" , table.concat( recorder ) ) )
|
return assert( love.filesystem.write( "demos/"..os.time()..".yod" , table.concat( recorder ) ) )
|
||||||
end
|
end
|
||||||
|
|
85
scores.lua
85
scores.lua
|
@ -2,31 +2,61 @@ local love = love
|
||||||
local scores = {}
|
local scores = {}
|
||||||
local highScores = {}
|
local highScores = {}
|
||||||
|
|
||||||
|
local letters = {
|
||||||
|
letters = { "D", "C", "B", "A", "S", "SS", "SSS" },
|
||||||
|
ticks = { 50000, 14400, 12000, 10000, 8000, 6000, 5000 },
|
||||||
|
streaks = { 1, 20, 40, 60, 80, 100, 120 },
|
||||||
|
score = { 0, 5, 10, 22, 56, 150, 300 },
|
||||||
|
}
|
||||||
|
|
||||||
|
letters.letters[0] = "!"
|
||||||
|
|
||||||
|
local function ScoreToLetter( ticks, streak, score )
|
||||||
|
local streakTier, ticksTier, scoreTier = 0, 0, 0
|
||||||
|
|
||||||
|
for i, threshold in ipairs( letters.ticks ) do
|
||||||
|
if ticks < threshold then ticksTier = i end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, threshold in ipairs( letters.streaks ) do
|
||||||
|
if streak > threshold then streakTier = i end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, threshold in ipairs( letters.score ) do
|
||||||
|
if score > threshold then scoreTier = i end
|
||||||
|
end
|
||||||
|
|
||||||
|
return letters.letters[ticksTier], letters.letters[streakTier], letters.letters[scoreTier]
|
||||||
|
end
|
||||||
|
|
||||||
function scores.OnImpact( tick, isHitSuccessful )
|
function scores.OnImpact( tick, isHitSuccessful )
|
||||||
local score = 0
|
local score = 0
|
||||||
if isHitSuccessful then
|
if isHitSuccessful then
|
||||||
scores.streak = scores.streak + 1
|
scores.streak = scores.streak + 1
|
||||||
|
scores.longestStreak = math.max( scores.streak, scores.longestStreak )
|
||||||
else
|
else
|
||||||
table.insert( scores.streaks, scores.streak)
|
table.insert( scores.streaks, scores.streak)
|
||||||
scores.streak = 0
|
scores.streak = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, streak in ipairs( scores.streaks ) do
|
for i, streak in ipairs( scores.streaks ) do
|
||||||
score = score + streak * streak
|
score = score + math.pow( streak, 1.7 )
|
||||||
end
|
end
|
||||||
|
|
||||||
scores.score = score / math.pow( tick / 120.0, 1.5 )
|
scores.score = score / ( ( tick / 120.0 ) - 36.0 )
|
||||||
scores.t = tick
|
scores.t = tick
|
||||||
end
|
end
|
||||||
|
|
||||||
function scores.Reset()
|
function scores.Reset()
|
||||||
scores.score = 0
|
scores.score = 0
|
||||||
scores.streak = 0
|
scores.streak = 0
|
||||||
|
scores.longestStreak = 0
|
||||||
|
scores.highScore = scores.LoadHighScores()
|
||||||
scores.streaks = {}
|
scores.streaks = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function scores.Get()
|
function scores.Get()
|
||||||
|
return scores.score
|
||||||
end
|
end
|
||||||
|
|
||||||
function scores.Save()
|
function scores.Save()
|
||||||
|
@ -36,24 +66,53 @@ function scores.Save()
|
||||||
if highScores[j] < scores.score then break end
|
if highScores[j] < scores.score then break end
|
||||||
end
|
end
|
||||||
table.insert( highScores, i )
|
table.insert( highScores, i )
|
||||||
|
scores.highScore = math.max( scores.score, scores.highScore )
|
||||||
end
|
end
|
||||||
|
|
||||||
function scores.LoadHighScores()
|
function scores.LoadHighScores()
|
||||||
|
local gameList = assert( love.filesystem.getDirectoryItems( "demos" ) )
|
||||||
|
local highScore = 0
|
||||||
|
for i, name in ipairs( gameList ) do
|
||||||
|
local s = love.filesystem.read( "demos/"..name, 64 )
|
||||||
|
if ( s:len() > 32 ) then
|
||||||
|
local gamescore, gameticks = love.data.unpack( "!16<dJ", s, 1)
|
||||||
|
highScore = math.max( gamescore, highScore )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return highScore
|
||||||
end
|
end
|
||||||
|
|
||||||
function scores.RenderHighScores()
|
function scores.RenderHighScores()
|
||||||
love.graphics.setColor( 1, 1, 1, 1 )
|
local wb = options["high contrast"].value and 0 or 1
|
||||||
love.graphics.printf( "Streak:."..scores.score, 0, 0, -1, "center" )
|
love.graphics.setColor( wb, wb, wb, 1 )
|
||||||
love.graphics.printf( "Score:."..scores.score, 0, 0, -1, "center" )
|
local h = 1.0 * love.graphics.getFont():getHeight()
|
||||||
|
local y = 0.5 * love.graphics.getHeight()
|
||||||
|
|
||||||
|
local lTick, lStreak, lScore = ScoreToLetter( scores.t, scores.longestStreak, scores.score )
|
||||||
love.graphics.printf(
|
love.graphics.printf(
|
||||||
string.format( "time:\t%.2f\nstreak:\t%d\nscore:%.2f", scores.t / 120.0, scores.streak, scores.score):gsub( "%.", "," ),
|
table.concat{
|
||||||
0, 0.5 * love.graphics.getHeight() - 2.0* love.graphics.getFont():getHeight(),
|
"time: ",
|
||||||
love.graphics.getWidth(),
|
string.format("%.1f", scores.t / 120.0):gsub("%.", ","),
|
||||||
"center"
|
".",
|
||||||
)
|
lTick,
|
||||||
|
"\n",
|
||||||
|
"streak: ",
|
||||||
|
scores.longestStreak,
|
||||||
|
".",
|
||||||
|
lStreak,
|
||||||
|
"\n",
|
||||||
|
"score: ",
|
||||||
|
string.format("%.1f", scores.score ):gsub("%.", ","),
|
||||||
|
".",
|
||||||
|
lScore,
|
||||||
|
"\n",
|
||||||
|
"record: ",
|
||||||
|
string.format("%.1f", math.max( scores.highScore, scores.score )):gsub("%.", ","),
|
||||||
|
".!\n"
|
||||||
|
},
|
||||||
|
love.graphics.getWidth() * 0.5 - 250, y - 2 * h, 500, "justify" )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scores.highScore = scores.LoadHighScores()
|
||||||
|
|
||||||
return scores
|
return scores
|
|
@ -10,12 +10,12 @@ end
|
||||||
sp.Draw = function( t )
|
sp.Draw = function( t )
|
||||||
local cx, cy = love.graphics.getDimensions()
|
local cx, cy = love.graphics.getDimensions()
|
||||||
cx, cy = 0.5 * cx, 0.5 * cy
|
cx, cy = 0.5 * cx, 0.5 * cy
|
||||||
love.graphics.setColor( 1.0, 1.0, 1.0, 0.5 )
|
love.graphics.setColor( 1.0, 1.0, 1.0, options["high contrast"].value and 0.2 or 0.5)
|
||||||
|
|
||||||
if #t == 1 then
|
if #t == 1 then
|
||||||
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 128 )
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 128 )
|
||||||
elseif #t == 2 then
|
elseif #t == 2 then
|
||||||
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 144, cy - 96, 0, 0.75, 0.75 )
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 160, cy - 96, 0, 0.75, 0.75 )
|
||||||
love.graphics.draw( sp[t[2]] or sp.pilin, cx - 16, cy - 96, 0, 0.75, 0.75 )
|
love.graphics.draw( sp[t[2]] or sp.pilin, cx - 16, cy - 96, 0, 0.75, 0.75 )
|
||||||
elseif #t == 3 then
|
elseif #t == 3 then
|
||||||
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 64, 0, 0.5, 0.5 )
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 64, 0, 0.5, 0.5 )
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
46
text.lua
46
text.lua
|
@ -10,7 +10,7 @@ local poemLines = {[0] = 0}
|
||||||
local mt = { __index = function() return "linja" end }
|
local mt = { __index = function() return "linja" end }
|
||||||
|
|
||||||
local s = love.filesystem.read( "text/tok.txt" )
|
local s = love.filesystem.read( "text/tok.txt" )
|
||||||
local instrFont = love.graphics.newFont( 18 )
|
local instrFont = love.graphics.newFont( 24 )
|
||||||
local enFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 18 )
|
local enFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 18 )
|
||||||
local smallFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 24 )
|
local smallFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 24 )
|
||||||
local largeFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 64 )
|
local largeFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 64 )
|
||||||
|
@ -60,7 +60,24 @@ local function Draw( beat )
|
||||||
local foot = feet[ beat ]
|
local foot = feet[ beat ]
|
||||||
|
|
||||||
if beat == 1 then
|
if beat == 1 then
|
||||||
|
|
||||||
|
love.graphics.setColor(0, 0, 0, 0.5)
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 1, 1, 1, 1 )
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.rectangle( "fill",
|
||||||
|
0.5 * love.graphics.getWidth() - 250, 10,
|
||||||
|
500, 1.1 * largeFont:getHeight(), 10, 10 )
|
||||||
|
|
||||||
|
love.graphics.rectangle( "fill",
|
||||||
|
0.5 * love.graphics.getWidth() - 200, love.graphics.getHeight() - 5.25 * instrFont:getHeight(),
|
||||||
|
400, 4.5 * instrFont:getHeight(), 50, 50 )
|
||||||
|
|
||||||
love.graphics.setColor(1.0, 1.0, 1.0, 1.0 )
|
love.graphics.setColor(1.0, 1.0, 1.0, 1.0 )
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0, 1 )
|
||||||
|
end
|
||||||
love.graphics.printf( "your.own.drum",
|
love.graphics.printf( "your.own.drum",
|
||||||
largeFont,
|
largeFont,
|
||||||
0, 0,
|
0, 0,
|
||||||
|
@ -68,22 +85,27 @@ local function Draw( beat )
|
||||||
"center"
|
"center"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
love.graphics.printf(
|
love.graphics.printf(
|
||||||
[[
|
[[
|
||||||
wasd move
|
WASD MOVE
|
||||||
space restart
|
SPACE RESTART
|
||||||
return recall
|
RETURN DEMOS
|
||||||
o options]],
|
O OPTIONS]],
|
||||||
instrFont,
|
instrFont,
|
||||||
0, love.graphics.getHeight() - 4 * instrFont:getHeight(),
|
0.5 * love.graphics.getWidth() - 150, love.graphics.getHeight() - 5 * instrFont:getHeight(),
|
||||||
love.graphics.getWidth(),
|
300,
|
||||||
"left"
|
"justify"
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0, 1 )
|
||||||
|
end
|
||||||
local lineNumber
|
local lineNumber
|
||||||
if poemLines[beat] < 2 then lineNumber = 0
|
if poemLines[beat] < 2 then lineNumber = 0
|
||||||
else lineNumber = 2 - poemLines[beat]
|
else lineNumber = 2 - poemLines[beat]
|
||||||
|
@ -96,6 +118,9 @@ o options]],
|
||||||
)
|
)
|
||||||
|
|
||||||
love.graphics.setColor(1.0, 1.0, 1.0, 1.0)
|
love.graphics.setColor(1.0, 1.0, 1.0, 1.0)
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0, 1 )
|
||||||
|
end
|
||||||
love.graphics.printf( foot,
|
love.graphics.printf( foot,
|
||||||
largeFont,
|
largeFont,
|
||||||
0, 0.87 * love.graphics.getHeight(),
|
0, 0.87 * love.graphics.getHeight(),
|
||||||
|
@ -104,6 +129,9 @@ o options]],
|
||||||
)
|
)
|
||||||
|
|
||||||
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0, 1 )
|
||||||
|
end
|
||||||
love.graphics.printf( poemLang[beat],
|
love.graphics.printf( poemLang[beat],
|
||||||
enFont,
|
enFont,
|
||||||
-8, 0,--(2 - poemLines[beat]) * smallFont:getHeight(),
|
-8, 0,--(2 - poemLines[beat]) * smallFont:getHeight(),
|
||||||
|
@ -115,7 +143,7 @@ o options]],
|
||||||
end
|
end
|
||||||
|
|
||||||
s = love.filesystem.read( "text/en.txt" )
|
s = love.filesystem.read( "text/en.txt" )
|
||||||
i = 1
|
i = 0
|
||||||
--Split string into lines.
|
--Split string into lines.
|
||||||
for line in s:gmatch( ".-\n") do
|
for line in s:gmatch( ".-\n") do
|
||||||
|
|
||||||
|
|
4
wave.lua
4
wave.lua
|
@ -201,6 +201,10 @@ local function Draw( score )
|
||||||
|
|
||||||
-- Blue circle.
|
-- Blue circle.
|
||||||
love.graphics.setColor( 91 / 255, 206 / 255, 250 / 255 )
|
love.graphics.setColor( 91 / 255, 206 / 255, 250 / 255 )
|
||||||
|
--Black circle.
|
||||||
|
if options["high contrast"].value then
|
||||||
|
love.graphics.setColor( 0, 0, 0 )
|
||||||
|
end
|
||||||
|
|
||||||
shader:send( "re", unpack( cur.dftre ) )
|
shader:send( "re", unpack( cur.dftre ) )
|
||||||
shader:send( "im", unpack( cur.dftim ) )
|
shader:send( "im", unpack( cur.dftim ) )
|
||||||
|
|
Loading…
Reference in New Issue