From da1fa7dc089d679c8f5d0a22e05106b100fdf540 Mon Sep 17 00:00:00 2001 From: entar Date: Fri, 11 Jul 2025 12:56:20 +0700 Subject: [PATCH] Made menu states save the selection, added module.processNote, added module.noteHit --- states/freeplaystate.lua | 3 +- states/menustate.lua | 4 +- states/optionsstate.lua | 4 +- states/playstate.lua | 145 ++++++++++++++++++++++----------------- states/weekstate.lua | 3 + 5 files changed, 92 insertions(+), 67 deletions(-) diff --git a/states/freeplaystate.lua b/states/freeplaystate.lua index 00f9124..9495346 100644 --- a/states/freeplaystate.lua +++ b/states/freeplaystate.lua @@ -1,3 +1,5 @@ +local curIndex = 1 + return function() local state = {} @@ -53,7 +55,6 @@ return function() local start = false local curSong = songs[1] - local curIndex = 1 local evilCurIndex = 1 local curDiffList = songs[1].difficulties diff --git a/states/menustate.lua b/states/menustate.lua index fbc1d76..e1fb2cb 100644 --- a/states/menustate.lua +++ b/states/menustate.lua @@ -11,6 +11,9 @@ local defaultSettings = { -- The way its in the JSON }, Offset = 0 } + +local currentOption = 1 + return function() ---@class StateClass local state = {} @@ -27,7 +30,6 @@ return function() options = "optionsstate", credits = "creditsstate" } - local currentOption = 1 local evilCurrentOption = 1 local optionSprites = {} local moving = false diff --git a/states/optionsstate.lua b/states/optionsstate.lua index cc2daf5..1b8d8f2 100644 --- a/states/optionsstate.lua +++ b/states/optionsstate.lua @@ -43,13 +43,13 @@ for index, category in next, categoryList do end end +local currentSetting = 1 + return function() ---@class StateClass local state = {} local getting - - local currentSetting = 1 local evilCurrentSetting = 1 local settings = json.parse(files.read_file(data.."/Settings.json")) diff --git a/states/playstate.lua b/states/playstate.lua index dbf7de9..c14f1eb 100644 --- a/states/playstate.lua +++ b/states/playstate.lua @@ -1,16 +1,66 @@ +-- I NEED THEM IMPORTS +local conductor = require("modules.conductor") +local json = require("modules.json") +local files = require("modules.files") +local socket = require("socket") +local logging = require("modules.logging") +-- I NEED THEM IMPORTS + +local rankWindows = { + { + rating = "sick", + hitWindow = 45, + spawnSplash = true, + score = 300 + }, + { + rating = "good", + hitWindow = 90, + spawnSplash = false, + score = 200 + }, + { + rating = "bad", + hitWindow = 135, + spawnSplash = false, + score = 100 + }, + { + rating = "shit", + hitWindow = 300, + spawnSplash = false, + score = 50 + } +} + +local receptorOffsets = { + arrow = Vector2(0, 0), + press = Vector2(-5, -5), + confirm = Vector2(35, 35) +} +local receptorAnims = { + "arrow", + "arrow", + "arrow", + "arrow" +} + +local directions = { + "LEFT", + "DOWN", + "UP", + "RIGHT" +} +local colors = { + "purple", + "blue", + "green", + "red" +} + local function state(songName, songDifficulty, show) local state = {} -- Returns needed functions for the state to work after loading it properly - -- I NEED THEM IMPORTS - - - local conductor = require("modules.conductor") - local json = require("modules.json") - local files = require("modules.files") - local socket = require("socket") - local logging = require("modules.logging") - -- I NEED THEM IMPORTS - local startTime = 0 local chartString @@ -96,58 +146,6 @@ local function state(songName, songDifficulty, show) local totalScore = 0 -- If you hit ALL sicks local accuracy = 100 - local rankWindows = { - { - rating = "sick", - hitWindow = 45, - spawnSplash = true, - score = 300 - }, - { - rating = "good", - hitWindow = 90, - spawnSplash = false, - score = 200 - }, - { - rating = "bad", - hitWindow = 135, - spawnSplash = false, - score = 100 - }, - { - rating = "shit", - hitWindow = 300, - spawnSplash = false, - score = 50 - } - } - - local receptorOffsets = { - arrow = Vector2(0, 0), - press = Vector2(-5, -5), - confirm = Vector2(35, 35) - } - local receptorAnims = { - "arrow", - "arrow", - "arrow", - "arrow" - } - - local directions = { - "LEFT", - "DOWN", - "UP", - "RIGHT" - } - local colors = { - "purple", - "blue", - "green", - "red" - } - local font = love.graphics.newFont("fonts/Phantomuff.ttf", 15) local biggerFont = love.graphics.newFont("fonts/Phantomuff.ttf", 30) local evenBiggerFont = love.graphics.newFont("fonts/FridayNightFunkin-Regular.ttf", 50) @@ -367,6 +365,12 @@ local function state(songName, songDifficulty, show) end end if closestNote then + for index, module in next, modules do + if module.noteHit then + module.noteHit(closestNote) + end + end + local rating = conductor:judgeNote(rankWindows, math.abs(closestNote.position - elapsed)) if rating.spawnSplash then @@ -464,7 +468,7 @@ local function state(songName, songDifficulty, show) elapsed = 0 - playing = true --countdown now + playing = true --We can truly play now startTime = socket.gettime() cdLength = 0 @@ -902,6 +906,11 @@ local function state(songName, songDifficulty, show) if note[2] >= 0 then local newNote = Note(note, section.mustHitSection) unspawnedNotes[#unspawnedNotes+1] = newNote + for index, module in next, modules do + if module.processNote then + module.processNote(newNote) + end + end if note[3] > 0 then local length = math.floor(note[3] / conductor.stepCrochet) @@ -910,6 +919,11 @@ local function state(songName, songDifficulty, show) local newHold = Note({note[1] + i * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true) unspawnedHoldNotes[#unspawnedHoldNotes+1] = newHold + for index, module in next, modules do + if module.processNote then + module.processNote(newHold) + end + end end local newHold = Note({note[1] + length * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true, true) unspawnedHoldNotes[#unspawnedHoldNotes+1] = newHold @@ -918,6 +932,11 @@ local function state(songName, songDifficulty, show) newHold.flipY = true end newHold.speed = speed + for index, module in next, modules do + if module.processNote then + module.processNote(newHold) + end + end end else local newEvent = { diff --git a/states/weekstate.lua b/states/weekstate.lua index 39227a4..66cf54c 100644 --- a/states/weekstate.lua +++ b/states/weekstate.lua @@ -72,6 +72,9 @@ return function() end function state.update(dt) + for index, shader in next, weekShaders do + shader:send("cur", orderIndex) + end render.updateSprites(dt) evilorderIndex = Lerp(evilorderIndex, orderIndex, .05)