From dfdb1023f6513014fc0f955142d2667d7bda80c9 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Sun, 16 Mar 2025 15:10:30 +0800 Subject: feat(controller): easier bullet management old approach: press number keys to put specific heart to the end of the line new approach: press Q or E to move the next bullet index --- objects/Player.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'objects') diff --git a/objects/Player.lua b/objects/Player.lua index aabc9e2..89b1b54 100644 --- a/objects/Player.lua +++ b/objects/Player.lua @@ -19,11 +19,13 @@ function Player.new() hearts = { "purpleheart", "redheart", "redheart", "redheart", "shinyheart", "shinyheart", "stickyheart" }, facing = Direction.DOWN, moving = false, - frameTimer = FrameTimer:new(config.frameRate, 2) + frameTimer = FrameTimer:new(config.frameRate, 2), }, Player) physics.bodifyObject(G.world, player) + player.nextBullet = #player.hearts + return player end @@ -68,7 +70,7 @@ end function Player:shoot(target) local hearts = self.hearts - local currentBullet = hearts[#hearts] + local currentBullet = hearts[self.nextBullet] -- red hearts and the last heart will take some more time to shoot if currentBullet == "redheart" or #hearts == 1 then @@ -89,7 +91,8 @@ function Player:shoot(target) -- shoot the bullet bullets.fire(currentBullet, target, self) - table.remove(self.hearts) + table.remove(self.hearts, self.nextBullet) + self.nextBullet = self.nextBullet - 1 self.shootCooldown = G.time + config.player.shoot.cooldown end -- cgit v1.2.3