aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/backgrounds/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--assets/images/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--assets/scripts/local2P.lua92
3 files changed, 92 insertions, 0 deletions
diff --git a/assets/backgrounds/.DS_Store b/assets/backgrounds/.DS_Store
index e272705..844a73c 100644
--- a/assets/backgrounds/.DS_Store
+++ b/assets/backgrounds/.DS_Store
Binary files differ
diff --git a/assets/images/.DS_Store b/assets/images/.DS_Store
index aa7349d..113ae90 100644
--- a/assets/images/.DS_Store
+++ b/assets/images/.DS_Store
Binary files differ
diff --git a/assets/scripts/local2P.lua b/assets/scripts/local2P.lua
index 54bb4ae..48bce2c 100644
--- a/assets/scripts/local2P.lua
+++ b/assets/scripts/local2P.lua
@@ -14,6 +14,18 @@ isNewRound = false
isFight = false
isGameOver = false
+debugConsoleActive = false
+debugInput = ""
+debugOutput = ""
+
+consoleKeycodes = {}
+for _, name in ipairs({"a","b","c","d","e","f","g","h","i","j","k","l","m",
+ "n","o","p","q","r","s","t","u","v","w","x","y","z",
+ "space","return","backspace","backquote","minus","0","1","2","3","4","5","6","7","8","9",
+ "(", ")", "%", "$", "."}) do
+ consoleKeycodes[name] = getKeycodeByName(name)
+end
+
winner = nil
math.randomseed(os.time())
@@ -29,6 +41,62 @@ knockbackMultiplierX = 22.4
knockbackMultiplierY = 7.73
minimalKnockbackMultiplierY = 40.3
+function EvaluateDebugCode(code)
+ local func, syntaxError = load(code, "debug", "t", _G)
+ if not func then
+ debugOutput = "Syntax error: " .. syntaxError
+ return
+ end
+
+ local success, result = pcall(func)
+ if not success then
+ debugOutput = "Runtime error: " .. result
+ else
+ if result == nil then
+ debugOutput = "Code executed successfully."
+ else
+ debugOutput = tostring(result)
+ end
+ end
+end
+
+function HandleDebugConsoleInput()
+ if not debugConsoleActive then return end
+
+ local shiftPressed = Input.isKeyDown("Left Shift")
+
+ for keyName, keycode in pairs(consoleKeycodes) do
+ if Input.isKeyPressedOnce(keyName) then
+ if keyName == "backspace" then
+ debugInput = debugInput:sub(1, -2)
+ elseif keyName == "return" then
+ EvaluateDebugCode(debugInput)
+ debugInput = ""
+ elseif #keyName == 1 then
+ if shiftPressed then
+ debugInput = debugInput .. keyName:upper()
+ else
+ debugInput = debugInput .. keyName
+ end
+ elseif keyName == "space" then
+ debugInput = debugInput .. " "
+ elseif keyName == "minus" then
+ debugInput = debugInput .. "-"
+ elseif keyName == "backquote" then
+ debugInput = debugInput .. "`"
+ end
+ end
+ end
+end
+
+function HandleDebugToggle()
+ if Input.isKeyPressedOnce("`") then
+ debugConsoleActive = not debugConsoleActive
+ debugInput = ""
+ debugOutput = ""
+ gamePaused = debugConsoleActive -- optional: pause game when console is open
+ end
+end
function SafeInitCharacter(character, default_x, default_y)
character.x = default_x
@@ -561,6 +629,23 @@ function DrawGameOverGraphic()
queueTextForRender(winner.name, fontFile, nameX, nameY, nameFontSize, 255, 255, 255, 255)
end
+function DrawDebugConsole()
+ if not debugConsoleActive then return end
+
+ local fontFile = "assets/fonts/OpenSans-Regular.ttf"
+ local fontSize = 20
+
+ -- Draw background rectangle for console input area
+ queueRectForRender(10, HEIGHT - 60, WIDTH - 20, 50, 0, 0, 0, 180)
+
+ -- Draw input text
+ queueTextForRender("> " .. debugInput, fontFile, 20, HEIGHT - 50, fontSize, 255, 255, 255, 255)
+
+ -- Draw output text above input
+ queueTextForRender(debugOutput, fontFile, 20, HEIGHT - 80, fontSize, 255, 255, 0, 255)
+end
+
+
function Update()
local maxDelta = 0.05 -- max 50 ms per frame
if deltaTime > maxDelta then
@@ -569,6 +654,13 @@ function Update()
Timer.update(deltaTime)
+ HandleDebugToggle()
+
+ if debugConsoleActive then
+ HandleDebugConsoleInput()
+ DrawDebugConsole()
+ end
+
if not gamePaused then
ApplyPhysics(player1Character)
ApplyPhysics(player2Character)