aboutsummaryrefslogtreecommitdiff
path: root/assets
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
parent37127e7d25d003b2526f06fa894736abe80b8454 (diff)
downloadshowdownofthesticks-50bc5a34d94580aa0836622d4328a43310eddb7f.tar.xz
showdownofthesticks-50bc5a34d94580aa0836622d4328a43310eddb7f.zip
CHARACTER SELECT IS FINISHED, WOOHOOOOOOOOOO
Diffstat (limited to 'assets')
-rw-r--r--assets/scripts/character-select.lua113
-rw-r--r--assets/scripts/local2P.lua1
-rw-r--r--assets/scripts/mainMenu.lua32
3 files changed, 126 insertions, 20 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
diff --git a/assets/scripts/local2P.lua b/assets/scripts/local2P.lua
index 635251b..f9ca84d 100644
--- a/assets/scripts/local2P.lua
+++ b/assets/scripts/local2P.lua
@@ -1,6 +1,5 @@
---@diagnostic disable: undefined-global
function Setup()
- setRenderPlayer(true)
end
function Update()
diff --git a/assets/scripts/mainMenu.lua b/assets/scripts/mainMenu.lua
index 7ed16cc..05272af 100644
--- a/assets/scripts/mainMenu.lua
+++ b/assets/scripts/mainMenu.lua
@@ -7,19 +7,34 @@ bigButtonWidth = 150;
bigButtonHeight = buttonHeight;
characterSelectType = ""
+Input = {
+ prevKeys = {},
+ isKeyPressedOnce = function(key)
+ local code = getKeycodeByName(key)
+ local wasDown = Input.prevKeys[code]
+ local isDown = keys[code]
+ Input.prevKeys[code] = isDown
+ return isDown and not wasDown
+ end,
+ isKeyDown = function(key)
+ local code = getKeycodeByName(key)
+ return keys[code]
+ end
+}
+
function Setup()
setBgImage("assets/backgrounds/city-background-1.png")
end
function Local2PButton()
- characterSelectType = "Local2P"
+ characterSelectType = "Local 2P"
dofile("assets/scripts/character-select.lua")
Setup()
end
function MultiplayerButton()
characterSelectType = "Multiplayer"
- dofile("assets/scripts/multiplayer.lua")
+ dofile("assets/scripts/character-select.lua")
Setup()
end
@@ -33,16 +48,5 @@ function Update()
queueButtonForRender("Local 2P", WIDTH // 2 - buttonWidth // 2, HEIGHT // 2 - buttonHeight // 2, buttonWidth, buttonHeight, "Local2PButton");
queueButtonForRender("Multiplayer", WIDTH // 2 - bigButtonWidth // 2, HEIGHT // 2 - bigButtonHeight // 2 + 55, bigButtonWidth, bigButtonHeight, "MultiplayerButton");
queueButtonForRender("Settings", WIDTH // 2 - buttonWidth // 2, HEIGHT // 2 - buttonHeight // 2 + 55 + 55, buttonWidth, buttonHeight, "SettingsButton");
- -- if keys[getKeycodeByName("RIGHT")] or keys[getKeycodeByName("D")] then
- -- movePlayer(movementSpeed, 0)
- -- end
- -- if keys[getKeycodeByName("LEFT")] or keys[getKeycodeByName("A")] then
- -- movePlayer(movementSpeed * -1, 0)
- -- end
- -- if keys[getKeycodeByName("DOWN")] or keys[getKeycodeByName("S")] then
- -- movePlayer(0, movementSpeed)
- -- end
- -- if keys[getKeycodeByName("UP")] or keys[getKeycodeByName("W")] then
- -- movePlayer(0, movementSpeed * -1)
- -- end
+ queueButtonForRender("Quit Game", WIDTH - bigButtonWidth - 20, 20, bigButtonWidth, bigButtonHeight, "quitGame")
end \ No newline at end of file