Added screen bopping (screen zoom) and return to menu (esc or song end)

This commit is contained in:
entar 2025-05-31 14:52:15 +07:00
parent 648528ba32
commit 94bac4afaa
5 changed files with 62 additions and 15 deletions

View File

@ -1,5 +1,6 @@
{
"Lua.diagnostics.disable": [
"different-requires"
"different-requires",
"need-check-nil"
]
}

View File

@ -23,9 +23,7 @@ local pressed = {false,false,false}
-- break
-- end
local gf = myTypes.Sprite("sprites/GF_assets.png", "sprites/GF_assets.json")
gf.position = myTypes.Vector2(30, 30)
gf:PlayAnimation("GF Dancing Beat", 24, true)
local gf
function love.update(dt)
if curState and curState.loaded then
@ -37,8 +35,11 @@ function love.update(dt)
end
elseif not curState then
if love.keyboard.isDown("return") then
gf:Destroy()
curState = state(curSong, curDiff)
curState.quit = function()
curState = nil
myTypes.destroyAllSprites()
end
curState.load()
elseif love.keyboard.isDown("down") and not pressed[1] then
curSong = next(songs, curSong)
@ -87,3 +88,5 @@ function love.draw()
love.graphics.print(string.format("Song: %s, Difficulty: %s, List: %s", curSong, curDiff, logging.dump(curDiffList)), love.graphics.newFont(15, "light"), love.graphics:getWidth()/2, love.graphics:getHeight()/2 + 150, 0, 1, 1, 200)
end
end
love.window.setMode(1280, 720, { fullscreen = false , resizable = true})

View File

@ -66,6 +66,21 @@ return function(songName, songDifficulty)
local keyBinds = {}
local function quit()
inst:stop()
inst:release()
voices:stop()
voices:release()
miss:stop()
miss:release()
state.quit()
end
local zoom = 1
local function checkNote(dir)
if pressed[dir] or holded[dir] then
pressed[dir] = false
@ -107,7 +122,7 @@ return function(songName, songDifficulty)
beat = conductor:getBeatRounded(elapsed)
if beat ~= oldBeat then
if beat % 2 == 0 then
if beat % 2 == 0 then
-- gf:PlayAnimation("BF NOTE LEFT", 30, false)
for name, character in next, characters do
if not character.singing then
@ -120,7 +135,10 @@ return function(songName, songDifficulty)
end
end
end
end
if beat % 4 == 0 then
zoom = zoom + .1
end
end
end
local section = chart.notes[math.floor(step / 16) + 1]
@ -158,6 +176,10 @@ return function(songName, songDifficulty)
pressed[4] = false
end
if love.keyboard.isDown("escape") then
state.quit()
end
for index, note in next, notes do
if note.position - conductor.songPosition < 0 then
if note.mustPress then
@ -214,25 +236,27 @@ return function(songName, songDifficulty)
end
if not inst:isPlaying() then
love.event.quit()
state.quit()
end
zoom = myMath.lerp(zoom, 1, .05)
end
local mainCanvas = love.graphics.newCanvas(1920, 1080)
function state.draw()
love.graphics.setCanvas(mainCanvas)
love.graphics.setCanvas(mainCanvas)
love.graphics.clear()
love.graphics.clear()
love.graphics.circle("fill", 960, 59, 50000)
love.graphics.circle("fill", 960, 59, 50000)
myTypes.drawSprites()
myTypes.drawSprites()
love.graphics.setCanvas()
love.graphics.setCanvas()
love.graphics.draw(mainCanvas, 0, 0, 0, (love.graphics:getHeight() / 1080) * (4/3), love.graphics:getHeight() / 1080)
love.graphics.draw(mainCanvas, (love.graphics:getHeight() * (4/3) - (love.graphics:getHeight()* (4/3)) * zoom) / 2, (love.graphics:getHeight()- love.graphics:getHeight() * zoom) / 2, 0, ((love.graphics:getHeight() / 1080) * (4/3)) * zoom, (love.graphics:getHeight() / 1080) * zoom)
end

View File

@ -32,6 +32,10 @@ function Vector2:Add(addVector2)
return module.Vector2(self.x + addVector2.x, self.y + addVector2.y)
end
function Vector2:Mul(num)
return module.Vector2(self.x * num, self.y * num)
end
function module.Vector2(x, y)
return setmetatable({x = x or 0, y = y or 0}, Vector2)
end
@ -105,6 +109,11 @@ function Sprite:Destroy()
for index, rect in next, Rects do
if rect == self then
table.remove(Rects, index)
-- for name, animation in next, rect.quads do
-- for index, quad in next, animation do
-- quad:release()
-- end
-- end
end
end
self = nil
@ -112,6 +121,11 @@ function Sprite:Destroy()
for index, sprite in next, Sprites do
if sprite == self then
table.remove(Sprites, index)
-- for name, animation in next, sprite.quads do
-- for index, quad in next, animation do
-- quad:release()
-- end
-- end
end
end
self = nil
@ -254,4 +268,9 @@ module.note = noteclass.note
characterclass.myTypes = module
module.character = characterclass.character
function module.destroyAllSprites()
Sprites = {}
Rects = {}
end
return module

View File

@ -1,5 +1,5 @@
{
"Keybinds": [
"d", "f", "j", "k"
"a", "s", "up", "right"
]
}