more character positioning

This commit is contained in:
entar 2025-05-26 23:08:11 +07:00
parent 0cb94d47f8
commit 0d92ec510f
3 changed files with 36 additions and 7 deletions

View File

@ -51,8 +51,8 @@ function loadGraphic(graphic)
local playing = false
local bf
local characters = {}
local stage = json.parse(files.read_file("stages/stage.json"))
local notes = {}
local directions = {
@ -64,7 +64,8 @@ local directions = {
function love.load()
bf = myTypes.character("bf")
characters.bf = myTypes.character("bf")
characters.bf.stagePosition = myTypes.Vector2(stage.boyfriend[1], stage.boyfriend[2])
for index, section in next, chart.notes do
for index, note in next, section.sectionNotes do
@ -85,7 +86,7 @@ local function checkNote(dir)
for index, note in next, notes do
if note.position - conductor.songPosition < 200 then
if note.mustPress and not note.pressed and note.direction == dir then
bf:PlayAnimation(directions[note.direction])
characters.bf:PlayAnimation(directions[note.direction])
note.pressed = true
table.remove(notes, index)
end
@ -116,6 +117,11 @@ function love.update(dt)
print("Beat", beat)
if beat % 2 == 0 then
-- gf:PlayAnimation("BF NOTE LEFT", 30, false)
for name, character in next, characters do
if not character.singing then
character:PlayAnimation("idle")
end
end
end
end
@ -139,11 +145,17 @@ function love.update(dt)
if note.mustPress then
miss:stop()
miss:play()
bf:PlayAnimation(directions[note.direction].."miss")
characters.bf:PlayAnimation(directions[note.direction].."miss")
table.remove(notes, index)
end
end
end
for name, character in next, characters do
if character.sprite.animation ~= "idle" and character.sprite.ended then
character:PlayAnimation("idle")
end
end
end
local mainCanvas = love.graphics.newCanvas(1920, 1080)

View File

@ -10,7 +10,8 @@ CharacterClass.__index = CharacterClass
function CharacterClass:PlayAnimation(name)
local animName = self.animations[name]
self.sprite:PlayAnimation(animName, self.animInfo[name].fps)
self.sprite.extraOffset = module.myTypes.Vector2(self.animInfo[name].offsets[1], self.animInfo[name].offsets[2])
self.sprite.extraOffset = module.myTypes.Vector2(self.animInfo[name].offsets[1] - self.stagePosition.x, self.animInfo[name].offsets[2] - self.stagePosition.y)
self.singing = name ~= "idle"
end
function module.character(name)
@ -32,7 +33,8 @@ function module.character(name)
animations = {},
animInfo = {},
sprite = sprite,
singing = false
singing = false,
stagePosition = module.myTypes.Vector2(0,0) -- Changeable
}, CharacterClass)
for index, alias in next, parsed.animations do

15
stages/stage.json Normal file
View File

@ -0,0 +1,15 @@
{
"directory": "",
"defaultZoom": 0.75,
"isPixelStage": false,
"boyfriend": [770, 100],
"girlfriend": [400, 130],
"opponent": [100, 100],
"hide_girlfriend": false,
"camera_boyfriend": [0, 0],
"camera_opponent": [0, 0],
"camera_girlfriend": [0, 0],
"camera_speed": 1
}