This repository has been archived on 2025-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
TaggedEngine/main.lua

118 lines
3.3 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")
local curSong = songs[1]
local curIndex = 1
local curDiffList = songs[1].difficulties
local curDiff = songs[1].difficulties[1]
local curDiffInd = 1
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 gettingKey
local settings = json.parse(files.read_file("settings.json"))
local keybinds = settings.Keybinds
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.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.name, curDiff, logging.dump(curDiffList)), font, love.graphics:getWidth()/2 - 20, love.graphics:getHeight()/2 + 150, 0, 1, 1, 200)
love.graphics.print(
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("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 love.keypressed(key, un, is)
if curState and stateLoaded then
curState.keypressed(key, un, is)
else
if not gettingKey then
if key == "return" then
curState = state(curSong.name, curDiff)
curState.quit = function()
curState = nil
stateLoaded = false
myTypes.destroyAllSprites()
end
curState.load()
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
curDiff = curDiffList[1]
elseif key == "right" then
if curDiffList[curDiffInd + 1] then
curDiff = curDiffList[curDiffInd + 1]
curDiffInd = curDiffInd + 1
else
curDiff = curDiffList[1]
curDiffInd = 1
end
elseif key == "1" then
gettingKey = 1
elseif key == "2" then
gettingKey = 2
elseif key == "3" then
gettingKey = 3
elseif key == "4" then
gettingKey = 3
elseif key == "0" then
settings.Downscroll = not settings.Downscroll
files.write_file("settings.json", json.stringify(settings))
end
else
keybinds[gettingKey] = key
gettingKey = nil
files.write_file("settings.json", json.stringify(settings))
end
end
end
love.window.setMode(1280, 720, { fullscreen = false , resizable = true})