aboutsummaryrefslogtreecommitdiff
path: root/assets/scripts/character-select.lua
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2025-06-14 20:56:29 +1200
committerArslaan Pathan <[email protected]>2025-06-14 20:56:29 +1200
commit50bc5a34d94580aa0836622d4328a43310eddb7f (patch)
tree30ca780d508cc6fc2042d396835afd9ae0fef839 /assets/scripts/character-select.lua
parent37127e7d25d003b2526f06fa894736abe80b8454 (diff)
downloadshowdownofthesticks-50bc5a34d94580aa0836622d4328a43310eddb7f.tar.xz
showdownofthesticks-50bc5a34d94580aa0836622d4328a43310eddb7f.zip
CHARACTER SELECT IS FINISHED, WOOHOOOOOOOOOO
Diffstat (limited to 'assets/scripts/character-select.lua')
-rw-r--r--assets/scripts/character-select.lua113
1 files changed, 108 insertions, 5 deletions
diff --git a/assets/scripts/character-select.lua b/assets/scripts/character-select.lua
index c3f7e52..1ea39d7 100644
--- a/assets/scripts/character-select.lua
+++ b/assets/scripts/character-select.lua
@@ -1,17 +1,35 @@
---@diagnostic disable: undefined-global
characters = {"Cobalt Phantom", "Emerald Venom", "Golden Radiance", "Crimson Reaper"}
-player1Character = ""
-player2Character = ""
+player1CharacterIndex = 1
+player2CharacterIndex = 2
+player1Character = characters[player1CharacterIndex]
+player2Character = characters[player2CharacterIndex]
+
+function StartGame()
+ if characterSelectType == "Local 2P" then
+ dofile("assets/scripts/local2P.lua")
+ end
+ if characterSelectType == "Multiplayer" then
+ dofile("assets/scripts/multiplayer.lua")
+ end
+ Setup()
+end
+
+function BackToMainMenu()
+ dofile("assets/scripts/mainMenu.lua")
+ Setup()
+end
function Setup()
- print(characterSelectType)
+ print("Using Character Select type: " .. characterSelectType) -- Debug print
end
function Update()
+ -- Title and subtitle/paragraph texts
local fontFile = "assets/fonts/OpenSans-Bold.ttf"
local fontSize = 50
- local text = "Character Select"
+ local text = "Character Select | " .. characterSelectType
local textWidth = getTextWidth(fontFile, fontSize, text)
local x = (WIDTH - textWidth) // 2
@@ -19,6 +37,91 @@ function Update()
queueTextForRender(text, fontFile, x, y, fontSize, 255, 255, 255, 255)
+ local fontFile = "assets/fonts/OpenSans-Regular.ttf"
+ local fontSize = 17
+ local text = "Player 1: Use A & D to cycle through characters"
+
+ local textWidth = getTextWidth(fontFile, fontSize, text)
+ local x = (WIDTH - textWidth) // 2
+ local y = 120
+
+ queueTextForRender(text, fontFile, x, y, fontSize, 255, 255, 255, 255)
+
+ local text = "Player 2: Use LEFT & RIGHT to cycle through characters"
+
+ local textWidth = getTextWidth(fontFile, fontSize, text)
+ local x = (WIDTH - textWidth) // 2
+ local y = 145
+
+ queueTextForRender(text, fontFile, x, y, fontSize, 255, 255, 255, 255)
+
+ -- Character Portraits & Names
+ local imageFile_player1 = "assets/characters/" .. player1Character .. "/portrait.png"
+ local imageFile_player2 = "assets/characters/" .. player2Character .. "/portrait.png"
+
+ local portraitWidth = 128
+
+ local nameFontFile = "assets/fonts/OpenSans-Bold.ttf"
+ local nameFontSize = 20
+
+ local p1_x = (WIDTH // 4) - (portraitWidth // 2)
+ queueTextureForRender(imageFile_player1, p1_x, 300)
+
+ local p1Name = player1Character
+ local p1NameWidth = getTextWidth(nameFontFile, nameFontSize, p1Name)
+ local p1TextX = (WIDTH // 4) - (p1NameWidth // 2)
+ queueTextForRender(p1Name, nameFontFile, p1TextX, 570, nameFontSize, 255, 255, 255, 255)
+
+ local p2_x = (WIDTH * 3 // 4) - (portraitWidth // 2)
+ queueTextureForRender(imageFile_player2, p2_x, 300)
+
+ local p2Name = player2Character
+ local p2NameWidth = getTextWidth(nameFontFile, nameFontSize, p2Name)
+ local p2TextX = (WIDTH * 3 // 4) - (p2NameWidth // 2)
+ queueTextForRender(p2Name, nameFontFile, p2TextX, 570, nameFontSize, 255, 255, 255, 255)
+
+
+ local function wrapIndex(index)
+ if index < 1 then
+ return #characters
+ elseif index > #characters then
+ return 1
+ else
+ return index
+ end
+ end
+
+ local function getNextValidIndex(currentIndex, direction, otherIndex)
+ local nextIndex = wrapIndex(currentIndex + direction)
+ while nextIndex == otherIndex do
+ nextIndex = wrapIndex(nextIndex + direction)
+ end
+ return nextIndex
+ end
+
+ -- Player 1 controls
+ if Input.isKeyPressedOnce("A") then
+ player1CharacterIndex = getNextValidIndex(player1CharacterIndex, -1, player2CharacterIndex)
+ player1Character = characters[player1CharacterIndex]
+ end
+
+ if Input.isKeyPressedOnce("D") then
+ player1CharacterIndex = getNextValidIndex(player1CharacterIndex, 1, player2CharacterIndex)
+ player1Character = characters[player1CharacterIndex]
+ end
+
+ -- Player 2 controls
+ if Input.isKeyPressedOnce("LEFT") then
+ player2CharacterIndex = getNextValidIndex(player2CharacterIndex, -1, player1CharacterIndex)
+ player2Character = characters[player2CharacterIndex]
+ end
+
+ if Input.isKeyPressedOnce("RIGHT") then
+ player2CharacterIndex = getNextValidIndex(player2CharacterIndex, 1, player1CharacterIndex)
+ player2Character = characters[player2CharacterIndex]
+ end
-
+ -- Start and back buttons
+ queueButtonForRender("START!", WIDTH // 2 - buttonWidth // 2, HEIGHT - (buttonHeight * 2), buttonWidth, buttonHeight, "StartGame");
+ queueButtonForRender("Back to Main Menu", WIDTH - 220 - 20, 20, 220, 50, "BackToMainMenu")
end \ No newline at end of file