diff options
| author | Arslaan Pathan <[email protected]> | 2025-07-01 22:51:28 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2025-07-01 22:51:28 +1200 |
| commit | 34da31b46a992ad176bfc320d7c5e4f278655e3f (patch) | |
| tree | e552f42c267e499b2d9ee4825b80998fe7dd0afa /assets | |
| parent | 4d8aa419a85f565d4c41ea02ceec2d9d722960de (diff) | |
| download | showdownofthesticks-34da31b46a992ad176bfc320d7c5e4f278655e3f.tar.xz showdownofthesticks-34da31b46a992ad176bfc320d7c5e4f278655e3f.zip | |
Add game over screen etc!
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/scripts/character-select.lua | 1 | ||||
| -rw-r--r-- | assets/scripts/local2P.lua | 67 |
2 files changed, 60 insertions, 8 deletions
diff --git a/assets/scripts/character-select.lua b/assets/scripts/character-select.lua index 394ed0f..4665a06 100644 --- a/assets/scripts/character-select.lua +++ b/assets/scripts/character-select.lua @@ -24,6 +24,7 @@ function BackToMainMenu() end function Setup() + stopAllSounds() print("Using Character Select type: " .. characterSelectType) -- Debug print end diff --git a/assets/scripts/local2P.lua b/assets/scripts/local2P.lua index b425085..54bb4ae 100644 --- a/assets/scripts/local2P.lua +++ b/assets/scripts/local2P.lua @@ -12,6 +12,9 @@ isKO = false isOverlay = true isNewRound = false isFight = false +isGameOver = false + +winner = nil math.randomseed(os.time()) @@ -313,6 +316,20 @@ function ApplyMinimalKnockback(attacker, target) -- target.x = target.x + direction * (target.knockback_counter * 0.7) end +function GameOver() + isGameOver = true + Timer.after(10, function () + dofile("assets/scripts/mainMenu.lua") + Setup() + end) + + if player1Character.wins > player2Character.wins then + winner = player1Character + else + winner = player2Character + end +end + function KillPlayer(character) if gamePaused then return end if character.isDead then return end @@ -337,7 +354,7 @@ function KillPlayer(character) if remaining_rounds > 0 then Setup() else - -- Handle game over here + GameOver() end isKO = false if remaining_rounds > 0 then @@ -476,11 +493,11 @@ function DrawKOGraphic() DrawOverlay() local fontFile = "assets/fonts/OpenSans-Bold.ttf" - local fontSize = 96 + local fontSize = 192 local text = "K.O." local textWidth = getTextWidth(fontFile, fontSize, text) - local x = (1280 - textWidth) / 2 - local y = 720 / 2 - fontSize / 2 + local x = (1280 - textWidth) // 2 + local y = 720 // 2 - fontSize // 2 queueTextForRender(text, fontFile, x + 5, y + 5, fontSize, 255, 255, 0, 255) queueTextForRender(text, fontFile, x, y, fontSize, 255, 0, 0, 255) @@ -515,6 +532,35 @@ function DrawFightGraphic() queueTextForRender(text, fontFile, x, y, fontSize, 255, 255, 0, 255) end +function DrawGameOverGraphic() + if not winner then return end + + setBgImage(backgrounds[1]) + + local fontFile = "assets/fonts/OpenSans-Bold.ttf" + local fontSize = 96 + local text = "WINNER" + local textWidth = getTextWidth(fontFile, fontSize, text) + local x = (1280 - textWidth) // 2 + local y = 20 + + queueTextForRender(text, fontFile, x, y, fontSize, 255, 255, 0, 255) + + local portraitWidth = 128 + local portraitHeight = 256 + local portraitX = (WIDTH // 2) - (portraitWidth // 2) + local portraitY = (HEIGHT // 2) - (portraitHeight // 2) + + queueTextureForRender(winner.asset_dir .. "/portrait.png", portraitX, portraitY) + + local nameFontSize = 24 + local nameWidth = getTextWidth(fontFile, nameFontSize, winner.name) + local nameX = (1280 - nameWidth) // 2 + local nameY = portraitY + portraitHeight + 20 + + queueTextForRender(winner.name, fontFile, nameX, nameY, nameFontSize, 255, 255, 255, 255) +end + function Update() local maxDelta = 0.05 -- max 50 ms per frame if deltaTime > maxDelta then @@ -531,10 +577,12 @@ function Update() HandleP2Input() end - queueTextureForRender(player1Character.current_sprite, math.ceil(player1Character.x), math.ceil(player1Character.y)) - queueTextureForRender(player2Character.current_sprite, math.ceil(player2Character.x), math.ceil(player2Character.y)) - DrawGroundTiles() - DrawUI() + if not isGameOver then + queueTextureForRender(player1Character.current_sprite, math.ceil(player1Character.x), math.ceil(player1Character.y)) + queueTextureForRender(player2Character.current_sprite, math.ceil(player2Character.x), math.ceil(player2Character.y)) + DrawGroundTiles() + DrawUI() + end if isKO then DrawKOGraphic() @@ -548,4 +596,7 @@ function Update() if isFight then DrawFightGraphic() end + if isGameOver then + DrawGameOverGraphic() + end end |
