Added settings and fixed some stuff

This commit is contained in:
Entarno54 2025-05-30 09:14:00 +07:00
parent 8e0b5e6044
commit 20d195c12b
5 changed files with 24 additions and 6 deletions

View File

@ -136,7 +136,7 @@
225
],
"camera_position": [
-500,
-900,
-20
],
"sing_duration": 4,

View File

@ -64,6 +64,8 @@ return function(songName, songDifficulty)
local receptors = {
}
local keyBinds = {}
local function checkNote(dir)
if pressed[dir] or holded[dir] then
pressed[dir] = false
@ -131,25 +133,25 @@ return function(songName, songDifficulty)
myTypes.updateSprites(dt)
if love.keyboard.isDown("a") then
if love.keyboard.isDown(keyBinds[1]) then
checkNote(1)
else
holded[1] = false
pressed[1] = false
end
if love.keyboard.isDown("s") then
if love.keyboard.isDown(keyBinds[2]) then
checkNote(2)
else
holded[2] = false
pressed[2] = false
end
if love.keyboard.isDown("up") then
if love.keyboard.isDown(keyBinds[3]) then
checkNote(3)
else
holded[3] = false
pressed[3] = false
end
if love.keyboard.isDown("right") then
if love.keyboard.isDown(keyBinds[4]) then
checkNote(4)
else
holded[4] = false
@ -271,12 +273,22 @@ return function(songName, songDifficulty)
myTypes.cameraTarget = myTypes.Vector2()
local settings = json.parse(files.read_file("settings.json"))
if not settings then
error("Failed to load settings")
end
keyBinds = settings.Keybinds
end
function state.finish()
inst:play()
voices:play()
while not inst:isPlaying() do
end --waiting till the song actually plays.
elapsed = 0
playing = true

View File

@ -169,7 +169,7 @@ function module.drawSprites()
love.graphics.draw(sprite.image, quad.quad, (sprite.position.x + (sprite.position.x - quad.offset.x - sprite.extraOffset.x) + cameraOffset.x), (sprite.position.y + (sprite.position.y - quad.offset.y - sprite.extraOffset.y) + cameraOffset.y), 0, quad.resize.x * (sprite.flipX and -1 or 1), quad.resize.y)
::continue:: -- Point itself
end
for index, rect in next, Rects do
if not rect.animation then goto continue end

View File

@ -9,6 +9,7 @@ CharacterClass.__index = CharacterClass
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: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)

5
settings.json Normal file
View File

@ -0,0 +1,5 @@
{
"Keybinds": [
"d", "f", "j", "k"
]
}