diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-16 21:05:30 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-16 21:05:30 +0800 |
| commit | 254afa93abe7dfec2f4bc1ee16a56436343c05f6 (patch) | |
| tree | bec2235f6cf026ac23b0312e3796bd6cbb69e889 | |
| parent | fe6d7b0fb352404dbdd9b688b52251bb69b3d8f4 (diff) | |
fix: next bullet index out of bounds
| -rw-r--r-- | logic/controller.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/logic/controller.lua b/logic/controller.lua index 066564e..302d764 100644 --- a/logic/controller.lua +++ b/logic/controller.lua @@ -9,9 +9,17 @@ end local function playerChangeNextBullet(key) if key == "q" then - G.player.nextBullet = G.player.nextBullet -1 + if G.player.nextBullet == 1 then + G.player.nextBullet = #G.player.hearts + else + G.player.nextBullet = G.player.nextBullet -1 + end elseif key == "e" then - G.player.nextBullet = G.player.nextBullet +1 + if G.player.nextBullet == #G.player.hearts then + G.player.nextBullet = 1 + else + G.player.nextBullet = G.player.nextBullet +1 + end end -- shortcut: press number key to move to a specific index |
