From 0d92ec510f7ca50ed8841c719cea566df0dcb8a1 Mon Sep 17 00:00:00 2001 From: entar Date: Mon, 26 May 2025 23:08:11 +0700 Subject: [PATCH] more character positioning --- main.lua | 22 +++++++++++++++++----- source/modules/types/character.lua | 6 ++++-- stages/stage.json | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 stages/stage.json diff --git a/main.lua b/main.lua index be14311..d87565e 100644 --- a/main.lua +++ b/main.lua @@ -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) diff --git a/source/modules/types/character.lua b/source/modules/types/character.lua index cd508ad..927ad57 100644 --- a/source/modules/types/character.lua +++ b/source/modules/types/character.lua @@ -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 diff --git a/stages/stage.json b/stages/stage.json new file mode 100644 index 0000000..37a71bd --- /dev/null +++ b/stages/stage.json @@ -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 +}