diff --git a/modules/conductor.lua b/modules/conductor.lua index a0688d5..29906dd 100644 --- a/modules/conductor.lua +++ b/modules/conductor.lua @@ -94,4 +94,14 @@ function conductor:mapBpmChanges(song) print("Mapped the song BPM changes.") end +function conductor:judgeNote(arr, diff) + for index, data in next, arr do + if diff <= data.hitWindow then + return data + end + end + + return arr[#arr] +end + return conductor \ No newline at end of file diff --git a/modules/states/playstate.lua b/modules/states/playstate.lua index 0b3913d..8d987dd 100644 --- a/modules/states/playstate.lua +++ b/modules/states/playstate.lua @@ -59,10 +59,27 @@ local function state(songName, songDifficulty) miss = 0, } - local hitWindows = { - [135] = "bad", - [90] = "good", - [45] = "sick" + local rankWindows = { + { + rating = "sick", + hitWindow = 15, + spawnSplash = true + }, + { + rating = "good", + hitWindow = 30, + spawnSplash = false + }, + { + rating = "bad", + hitWindow = 50, + spawnSplash = false + }, + { + rating = "shit", + hitWindow = 120, + spawnSplash = false + } } local directions = { @@ -71,6 +88,12 @@ local function state(songName, songDifficulty) "UP", "RIGHT" } + local colors = { + "purple", + "blue", + "green", + "red" + } local singVectors = { singLEFT = myTypes.Vector2(20, 0), @@ -94,10 +117,10 @@ local function state(songName, songDifficulty) } local font = love.graphics.newFont("fonts/Phantomuff.ttf", 15) - - local fps = 60 -- for the counter + local biggerFont = love.graphics.newFont("fonts/Phantomuff.ttf", 23) local receptors = {} + local splashes = {} local keyBinds = {} -- loaded from settings.json, if anything's wrong then check your settings.json @@ -128,7 +151,7 @@ local function state(songName, songDifficulty) local closestNote local closestIndex for index, note in next, notes do - if note.position - conductor.songPosition < 200 then + if note.position - conductor.songPosition < 230 then if note.mustPress and not note.pressed and note.direction == dir and (not closestNote or closestNote and note.position < closestNote.position) then closestNote = note closestIndex = index @@ -136,13 +159,13 @@ local function state(songName, songDifficulty) end end if closestNote then - local rating = "shit" - for window, rate in next, hitWindows do - if math.abs(closestNote.position - elapsed) <= window then - rating = rate - end + local rating = conductor:judgeNote(rankWindows, math.abs(closestNote.position - elapsed)) + + if rating.spawnSplash then + splashes[closestNote.direction]:PlayAnimation(string.format("note splash %s %s", colors[closestNote.direction], math.random(1, 2)), 24, false) end - ratings[rating] = ratings[rating] + 1 + + ratings[rating.rating] = ratings[rating.rating] + 1 characters.bf:PlayAnimation("sing"..directions[closestNote.direction]) closestNote.pressed = true notes[closestIndex] = nil @@ -280,8 +303,6 @@ local function state(songName, songDifficulty) zoom = myMath.lerp(zoom, 1, .05) - fps = 1000 / dt - if inst and inst:getVolume() ~= volume / 100 then inst:setVolume(volume / 100) voices:setVolume(volume / 100) @@ -291,6 +312,12 @@ local function state(songName, songDifficulty) quit() end + for index, splash in next, splashes do + if splash.animation and splash.ended then + splash:StopAnimation() + end + end + ::continue:: end @@ -312,7 +339,7 @@ local function state(songName, songDifficulty) love.graphics.print({{0,0,0,1}, string.format("FPS: %s \nVolume: %s", love.timer.getFPS(), volume)}, font) - love.graphics.print({{0,0,0,1}, string.format("Sick: %s \nGood: %s \nBad: %s \nShit: %s \nMiss: %s", ratings.sick, ratings.good, ratings.bad, ratings.shit, ratings.miss)}, font, 0, 20) + love.graphics.print({{0,0,0,1}, string.format("Sick: %s \nGood: %s \nBad: %s \nShit: %s \nMiss: %s", ratings.sick, ratings.good, ratings.bad, ratings.shit, ratings.miss)}, biggerFont, 0, 100) end love.window.setMode(1280, 720, { fullscreen = false , resizable = false}) @@ -377,6 +404,14 @@ local function state(songName, songDifficulty) receptor.ui = true -- So it doesnt move with the camera. receptors[i + 1] = receptor + + local splash = myTypes.Sprite("sprites/noteSplashes.png", "sprites/noteSplashes.json") + + splash.position = myTypes.Vector2(550 + (79* i), settings.Downscroll and 0 or 380) + splash.ui = true + + splashes[i + 1] = splash + end for i = 0, 3 do -- opponent receptors, purely graphics diff --git a/modules/types.lua b/modules/types.lua index 49ff01b..1a3aead 100644 --- a/modules/types.lua +++ b/modules/types.lua @@ -322,6 +322,11 @@ function Sprite:Frame(name, frame) self.frame = frame end +function Sprite:StopAnimation() + self.animation = nil + self.frame = 0 +end + noteclass.types = module module.note = noteclass.note diff --git a/modules/types/character.lua b/modules/types/character.lua index 6780049..15c6bd4 100644 --- a/modules/types/character.lua +++ b/modules/types/character.lua @@ -11,11 +11,11 @@ function CharacterClass:PlayAnimation(name) local animName = self.animations[name] local reOffset = self.flipX and -1 or 1 if self.animInfo[name].random then + self.sprite.extraOffset = module.myTypes.Vector2(self.animInfo[name].offsets[1] - self.stagePosition.x, self.animInfo[name].offsets[2] - self.stagePosition.y) self.sprite:PlayAnimation(animName..string.format("%s ", math.random(self.animInfo[name].random[1], self.animInfo[name].random[2])), self.animInfo[name].fps) - self.sprite.extraOffset = module.myTypes.Vector2(self.animInfo[name].offsets[1] - self.stagePosition.x, self.animInfo[name].offsets[2] - self.stagePosition.y) else - self.sprite:PlayAnimation(animName, self.animInfo[name].fps) self.sprite.extraOffset = module.myTypes.Vector2(self.animInfo[name].offsets[1] - self.stagePosition.x, self.animInfo[name].offsets[2] - self.stagePosition.y) + self.sprite:PlayAnimation(animName, self.animInfo[name].fps) end self.singing = name ~= "idle" and name ~= "danceLeft" and name ~= "danceRight" self.animation = name @@ -56,6 +56,7 @@ function module.character(name) end if newCharacter.animInfo["idle"] then + newCharacter.sprite.extraOffset = module.myTypes.Vector2(newCharacter.animInfo[name].offsets[1] - newCharacter.stagePosition.x, newCharacter.animInfo[name].offsets[2] - newCharacter.stagePosition.y) newCharacter:PlayAnimation("idle") else newCharacter:PlayAnimation("danceLeft") diff --git a/sprites/noteSplashes.json b/sprites/noteSplashes.json new file mode 100644 index 0000000..85e0054 --- /dev/null +++ b/sprites/noteSplashes.json @@ -0,0 +1,447 @@ +{ + "TextureAtlas": { + "SubTexture": [ + { + "_name": "note splash purple 10000", + "_x": "0", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 10001", + "_x": "0", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 10002", + "_x": "0", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 10003", + "_x": "0", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 10004", + "_x": "0", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 20000", + "_x": "210", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 20001", + "_x": "210", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 20002", + "_x": "210", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 20003", + "_x": "210", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash purple 20004", + "_x": "210", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 10000", + "_x": "420", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 10001", + "_x": "420", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 10002", + "_x": "420", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 10003", + "_x": "420", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 10004", + "_x": "420", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 20000", + "_x": "630", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 20001", + "_x": "630", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 20002", + "_x": "630", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 20003", + "_x": "630", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash blue 20004", + "_x": "630", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 10000", + "_x": "840", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 10001", + "_x": "840", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 10002", + "_x": "840", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 10003", + "_x": "840", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 10004", + "_x": "840", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 20000", + "_x": "1050", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 20001", + "_x": "1050", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 20002", + "_x": "1050", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 20003", + "_x": "1050", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash green 20004", + "_x": "1050", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 10000", + "_x": "1260", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 10001", + "_x": "1260", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 10002", + "_x": "1260", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 10003", + "_x": "1260", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 10004", + "_x": "1260", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 20000", + "_x": "1470", + "_y": "0", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 20001", + "_x": "1470", + "_y": "210", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 20002", + "_x": "1470", + "_y": "420", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 20003", + "_x": "1470", + "_y": "630", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + }, + { + "_name": "note splash red 20004", + "_x": "1470", + "_y": "840", + "_width": "210", + "_height": "210", + "_frameX": "-65", + "_frameY": "-70", + "_frameWidth": "210", + "_frameHeight": "210" + } + ], + "_imagePath": "noteSplashes.png" + } +} \ No newline at end of file diff --git a/sprites/noteSplashes.png b/sprites/noteSplashes.png new file mode 100644 index 0000000..64fa7d6 Binary files /dev/null and b/sprites/noteSplashes.png differ diff --git a/stages/limo.lua b/stages/limo.lua index edde30c..3587ebd 100644 --- a/stages/limo.lua +++ b/stages/limo.lua @@ -2,8 +2,12 @@ local myTypes = require("modules.types") local dancers = {} +local curSong + return { onCreate = function(song) + curSong = song + dancers = {} local sunset = myTypes.Image("images/limo/limoSunset.png", .2)