265 lines
7.7 KiB
Lua
265 lines
7.7 KiB
Lua
local state = require("modules.states.playstate")
|
|
|
|
local myMath = require("modules.math")
|
|
local myTypes = require("modules.types")
|
|
local files = require("modules.files")
|
|
local json = require("modules.json")
|
|
local logging = require("modules.logging")
|
|
|
|
local songs = require("charts.songs")
|
|
|
|
curChar = "bf" --this needs to be global
|
|
|
|
local curSong = songs[1]
|
|
local curIndex = 1
|
|
local evilCurIndex = 1
|
|
local curDiffList = songs[1].difficulties
|
|
|
|
local curDiff = songs[1].difficulties[1]
|
|
local curDiffInd = 1
|
|
|
|
local diffIMG
|
|
local charIcon
|
|
local iconNum = math.random(1,3)
|
|
|
|
local curState = nil
|
|
local stateLoaded = false
|
|
|
|
local pressed = {false,false,false}
|
|
|
|
local bg
|
|
local logo
|
|
local gf
|
|
local freaky = love.audio.newSource("sounds/freakyMenu.ogg", "stream")
|
|
local charSwapSND = love.audio.newSource("sounds/CS_select.ogg", "stream")
|
|
charSwapSND:setVolume(0.25)
|
|
|
|
local left
|
|
|
|
local function setup()
|
|
bg = myTypes.Image("images/menuBG.png", 0)
|
|
bg.ui = false
|
|
bg.layer = -10
|
|
|
|
gf = myTypes.Sprite("sprites/gfDanceTitle.png", "sprites/gfDanceTitle.json")
|
|
gf:PlayAnimation("gfDance", 24, true)
|
|
gf.position = myTypes.Vector2(340, 60)
|
|
for index, rect in next, gf.quads.gfDance do
|
|
rect.resize = myTypes.Vector2(0.7,.7)
|
|
end
|
|
gf.layer = 3
|
|
|
|
left = myTypes.Image("images/MenuLeft.png")
|
|
left.layer = 0
|
|
left.resize = myTypes.Vector2(2, 1)
|
|
|
|
local arrow = myTypes.Image("images/eventArrow.png")
|
|
arrow.position.y = 330
|
|
arrow.layer = 1
|
|
arrow.resize = myTypes.Vector2(.5,.5)
|
|
|
|
diffIMG = myTypes.Sprite("images/diff/diffList.png", "images/diff/diffList.json") --look there was a different plan going in
|
|
diffIMG:PlayAnimation(curDiff, 24, false)
|
|
diffIMG.position = myTypes.Vector2(200, 320)
|
|
diffIMG.layer = 2
|
|
|
|
charIcon = myTypes.Sprite("sprites/menu/charIcons.png", "sprites/menu/charIcons.json")
|
|
charIcon:PlayAnimation(curChar..iconNum, 24, false)
|
|
charIcon.position = myTypes.Vector2(175, 100)
|
|
charIcon.resize = myTypes.Vector2(0.25, 0.25) --this doesnt work and idk why
|
|
charIcon.layer = 2 --since they won't overlap this is ok i think
|
|
|
|
freaky:play()
|
|
end
|
|
|
|
local font = love.graphics.newFont("fonts/FridayNightFunkin-Regular.ttf", 40)
|
|
|
|
local gettingKey
|
|
|
|
local settings = json.parse(files.read_file("settings.json"))
|
|
local keybinds = settings.Keybinds
|
|
local scroll = love.audio.newSource("sounds/ui/scrollMenu.ogg", "static")
|
|
local confirm = love.audio.newSource("sounds/ui/confirmMenu.ogg", "static")
|
|
|
|
function love.update(dt)
|
|
if curState and curState.loaded then
|
|
if stateLoaded then
|
|
curState.update(dt)
|
|
else
|
|
stateLoaded = true -- skipping this update frame
|
|
curState.finish()
|
|
end
|
|
elseif not curState then
|
|
myTypes.render.cameraTarget = myTypes.Vector2(0,0)
|
|
myTypes.updateSprites(dt)
|
|
|
|
end
|
|
end
|
|
|
|
function love.draw()
|
|
if curState and stateLoaded then
|
|
curState.draw()
|
|
else
|
|
|
|
myTypes.drawSprites()
|
|
|
|
evilCurIndex = myMath.lerp(evilCurIndex, curIndex, .3)
|
|
|
|
for index, song in next, songs do
|
|
love.graphics.print({{0,0,0}, song.name}, font, 300 + (8 * (index - evilCurIndex)), love.graphics:getHeight()/2 + (50 * (index - evilCurIndex - .7)), 0, 1, 1, 200)
|
|
end
|
|
|
|
--love.graphics.print({{0,0,0}, curDiff}, font, 400, 660)
|
|
|
|
love.graphics.print(
|
|
{{0,0,0}, string.format("Left: %s, Down: %s, Up: %s, Right: %s \nDownscroll: %s",
|
|
keybinds[1],
|
|
keybinds[2],
|
|
keybinds[3],
|
|
keybinds[4],
|
|
settings.Downscroll
|
|
)})
|
|
love.graphics.print({{0,0,0}, "Press 1 to change LEFT \nPress 2 to change DOWN \nPress 3 to change UP \nPress 4 to change RIGHT \nPress 0 to toggle DOWNSCROLL"}, 500, 0)
|
|
end
|
|
end
|
|
|
|
function run()
|
|
confirm:stop()
|
|
confirm:play()
|
|
|
|
myTypes.destroyAllSprites()
|
|
freaky:stop()
|
|
|
|
curState = state(curSong.name, curDiff)
|
|
|
|
curState.quit = function()
|
|
curState = nil
|
|
stateLoaded = false
|
|
myTypes.destroyAllSprites()
|
|
setup()
|
|
end
|
|
curState.restart = function()
|
|
curState = nil
|
|
stateLoaded = false
|
|
myTypes.destroyAllSprites()
|
|
|
|
run()
|
|
end
|
|
curState.load()
|
|
end
|
|
|
|
function love.keypressed(key, un, is)
|
|
if curState and stateLoaded then
|
|
curState.keypressed(key, un, is)
|
|
elseif not curState then
|
|
if not gettingKey then
|
|
if key == "return" then
|
|
run()
|
|
elseif key == "down" then
|
|
curIndex, curSong = next(songs, curIndex)
|
|
if not curSong then
|
|
curIndex, curSong = next(songs)
|
|
curDiffList = curSong.difficulties
|
|
else
|
|
curDiffList = curSong.difficulties
|
|
end
|
|
curDiffInd = 1
|
|
curDiff = curDiffList[1]
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
scroll:stop()
|
|
scroll:play()
|
|
elseif key == "up" then --the solution was so stupid easy
|
|
if songs[curIndex - 1] then
|
|
curSong = songs[curIndex - 1]
|
|
curDiffList = songs[curIndex - 1].difficulties
|
|
curDiffInd = 1
|
|
curDiff = curDiffList[curDiffInd]
|
|
curIndex = curIndex - 1
|
|
else
|
|
curSong = songs[#songs]
|
|
curIndex = #songs
|
|
curDiffList = songs[curIndex].difficulties
|
|
curDiffInd = 1
|
|
curDiff = curDiffList[curDiffInd]
|
|
end
|
|
curDiffInd = 1
|
|
curDiff = curDiffList[1]
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
scroll:stop()
|
|
scroll:play()
|
|
elseif key == "right" then
|
|
if curDiffList[curDiffInd + 1] then
|
|
curDiff = curDiffList[curDiffInd + 1]
|
|
curDiffInd = curDiffInd + 1
|
|
else
|
|
curDiff = curDiffList[1]
|
|
curDiffInd = 1
|
|
end
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
scroll:stop()
|
|
scroll:play()
|
|
elseif key == "left" then
|
|
if curDiffList[curDiffInd - 1] then
|
|
curDiff = curDiffList[curDiffInd - 1]
|
|
curDiffInd = curDiffInd - 1
|
|
else
|
|
curDiff = curDiffList[#curDiffList]
|
|
curDiffInd = #curDiffList
|
|
end
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
scroll:stop()
|
|
scroll:play()
|
|
elseif key == "p" then --changes character to/from pico hopefully
|
|
if curChar == "bf" then
|
|
songs = require("charts.picoSongs") --change which catalogue is available
|
|
--reset the index's nd shit
|
|
curSong = songs[1]
|
|
curIndex = 1
|
|
evilCurIndex = 1
|
|
curDiffInd = 1
|
|
curDiffList = songs[curIndex].difficulties
|
|
curDiff = curDiffList[1]
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
curChar = "pico"
|
|
iconNum = math.random(1,3)
|
|
charIcon:PlayAnimation(curChar..iconNum, 24, false)
|
|
charSwapSND:stop()
|
|
charSwapSND:play()
|
|
else
|
|
songs = require("charts.songs")
|
|
curSong = songs[1]
|
|
curIndex = 1
|
|
evilCurIndex = 1
|
|
curDiffInd = 1
|
|
curDiffList = songs[curIndex].difficulties
|
|
curDiff = curDiffList[1]
|
|
diffIMG:PlayAnimation(curDiff, 24, true)
|
|
curChar = "bf"
|
|
iconNum = math.random(1,3)
|
|
charIcon:PlayAnimation(curChar..iconNum, 24, false)
|
|
charSwapSND:stop()
|
|
charSwapSND:play()
|
|
end
|
|
elseif tonumber(key) and tonumber(key) < 5 then
|
|
if key == "0" then
|
|
settings.Downscroll = not settings.Downscroll
|
|
files.write_file("settings.json", json.stringify(settings))
|
|
else
|
|
gettingKey = tonumber(key)
|
|
end
|
|
end
|
|
else
|
|
keybinds[gettingKey] = key
|
|
gettingKey = nil
|
|
|
|
files.write_file("settings.json", json.stringify(settings))
|
|
|
|
confirm:stop()
|
|
confirm:play()
|
|
end
|
|
end
|
|
end
|
|
|
|
love.window.setMode(1280, 720, { fullscreen = false , resizable = true})
|
|
|
|
setup() |