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 = json.parse(files.read_file("songs.json")) local curSong = "dad-battle" local curDiffList = {"erect"} local curDiff = "erect" local curState = nil local stateLoaded = false local pressed = {false,false,false} local font = love.graphics.newFont("fonts/Phantomuff.ttf", 25) -- for index, song in next, songs do -- curSong = index -- curDiff = song[1] -- break -- end local gf 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 if love.keyboard.isDown("return") then elseif love.keyboard.isDown("down") and not pressed[1] then pressed[1] = true elseif love.keyboard.isDown("right") and not pressed[2] then local curDiffNum = 0 for index, diff in next, curDiffList do if diff == curDiff then curDiffNum = index + 1 end end curDiff = curDiffList[curDiffNum] or curDiff pressed[2] = true elseif love.keyboard.isDown("left") and not pressed[3] then local curDiffNum = 0 for index, diff in next, curDiffList do if diff == curDiff then curDiffNum = index - 1 end end curDiff = curDiffList[curDiffNum] or curDiff pressed[3] = true elseif not love.keyboard.isDown("down") then pressed[1] = false elseif not love.keyboard.isDown("right") then pressed[2] = false elseif not love.keyboard.isDown("left") then pressed[3] = false end myTypes.updateSprites(dt) end end function love.draw() if curState and stateLoaded then curState.draw() else myTypes.drawSprites() love.graphics.print(string.format("Song: %s, Difficulty: %s, List: %s", curSong, curDiff, logging.dump(curDiffList)), font, love.graphics:getWidth()/2 - 20, love.graphics:getHeight()/2 + 150, 0, 1, 1, 200) end end function love.keypressed(key, un, is) if curState and stateLoaded then curState.keypressed(key, un, is) else if key == "return" then curState = state(curSong, curDiff) curState.quit = function() curState = nil stateLoaded = false myTypes.destroyAllSprites() end curState.load() elseif key == "down" then curSong = next(songs, curSong) if not curSong then curSong = next(songs) curDiffList = songs[curSong] else curDiffList = songs[curSong] end curDiff = curDiffList[1] end end end love.window.setMode(1280, 720, { fullscreen = false , resizable = true})