diff options
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/backgrounds/.DS_Store | bin | 0 -> 6148 bytes | |||
| -rw-r--r-- | assets/backgrounds/backgrounds-data.lua | 10 | ||||
| -rw-r--r-- | assets/backgrounds/city-background-2.png | bin | 0 -> 279022 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-3.png | bin | 0 -> 330100 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-4.png | bin | 0 -> 302940 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-5.png | bin | 0 -> 336241 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-6.png | bin | 0 -> 282392 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-7.png | bin | 0 -> 292384 bytes | |||
| -rw-r--r-- | assets/backgrounds/city-background-8.png | bin | 0 -> 255993 bytes | |||
| -rw-r--r-- | assets/characters/.DS_Store | bin | 10244 -> 10244 bytes | |||
| -rw-r--r-- | assets/characters/Cobalt Phantom/.DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | assets/characters/Emerald Venom/.DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | assets/characters/Golden Radiance/.DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | assets/characters/characters-data.lua | 8 | ||||
| -rw-r--r-- | assets/scripts/local2P.lua | 104 |
15 files changed, 103 insertions, 19 deletions
diff --git a/assets/backgrounds/.DS_Store b/assets/backgrounds/.DS_Store Binary files differnew file mode 100644 index 0000000..e272705 --- /dev/null +++ b/assets/backgrounds/.DS_Store diff --git a/assets/backgrounds/backgrounds-data.lua b/assets/backgrounds/backgrounds-data.lua new file mode 100644 index 0000000..087ddf9 --- /dev/null +++ b/assets/backgrounds/backgrounds-data.lua @@ -0,0 +1,10 @@ +return { + "assets/backgrounds/city-background-1.png", + "assets/backgrounds/city-background-2.png", + "assets/backgrounds/city-background-3.png", + "assets/backgrounds/city-background-4.png", + "assets/backgrounds/city-background-5.png", + "assets/backgrounds/city-background-6.png", + "assets/backgrounds/city-background-7.png", + "assets/backgrounds/city-background-8.png", +}
\ No newline at end of file diff --git a/assets/backgrounds/city-background-2.png b/assets/backgrounds/city-background-2.png Binary files differnew file mode 100644 index 0000000..de3f04f --- /dev/null +++ b/assets/backgrounds/city-background-2.png diff --git a/assets/backgrounds/city-background-3.png b/assets/backgrounds/city-background-3.png Binary files differnew file mode 100644 index 0000000..a1b625b --- /dev/null +++ b/assets/backgrounds/city-background-3.png diff --git a/assets/backgrounds/city-background-4.png b/assets/backgrounds/city-background-4.png Binary files differnew file mode 100644 index 0000000..147989b --- /dev/null +++ b/assets/backgrounds/city-background-4.png diff --git a/assets/backgrounds/city-background-5.png b/assets/backgrounds/city-background-5.png Binary files differnew file mode 100644 index 0000000..971e57a --- /dev/null +++ b/assets/backgrounds/city-background-5.png diff --git a/assets/backgrounds/city-background-6.png b/assets/backgrounds/city-background-6.png Binary files differnew file mode 100644 index 0000000..2947551 --- /dev/null +++ b/assets/backgrounds/city-background-6.png diff --git a/assets/backgrounds/city-background-7.png b/assets/backgrounds/city-background-7.png Binary files differnew file mode 100644 index 0000000..28ada47 --- /dev/null +++ b/assets/backgrounds/city-background-7.png diff --git a/assets/backgrounds/city-background-8.png b/assets/backgrounds/city-background-8.png Binary files differnew file mode 100644 index 0000000..6928a6b --- /dev/null +++ b/assets/backgrounds/city-background-8.png diff --git a/assets/characters/.DS_Store b/assets/characters/.DS_Store Binary files differindex 358c1b2..a4ae90d 100644 --- a/assets/characters/.DS_Store +++ b/assets/characters/.DS_Store diff --git a/assets/characters/Cobalt Phantom/.DS_Store b/assets/characters/Cobalt Phantom/.DS_Store Binary files differindex 9ec0b2a..9955791 100644 --- a/assets/characters/Cobalt Phantom/.DS_Store +++ b/assets/characters/Cobalt Phantom/.DS_Store diff --git a/assets/characters/Emerald Venom/.DS_Store b/assets/characters/Emerald Venom/.DS_Store Binary files differindex 5f50018..472db25 100644 --- a/assets/characters/Emerald Venom/.DS_Store +++ b/assets/characters/Emerald Venom/.DS_Store diff --git a/assets/characters/Golden Radiance/.DS_Store b/assets/characters/Golden Radiance/.DS_Store Binary files differindex e1664d3..7f88958 100644 --- a/assets/characters/Golden Radiance/.DS_Store +++ b/assets/characters/Golden Radiance/.DS_Store diff --git a/assets/characters/characters-data.lua b/assets/characters/characters-data.lua index d3cef43..a90849e 100644 --- a/assets/characters/characters-data.lua +++ b/assets/characters/characters-data.lua @@ -1,7 +1,7 @@ return { { name = "Cobalt Phantom", - health = 100, + lives = 3, speed = 5, moves = {"teleportation", "quick_dashes", "smoke_screens", "strikes_from_the_shadows"}, asset_dir = "assets/characters/Cobalt Phantom", @@ -9,7 +9,7 @@ return { }, { name = "Emerald Venom", - health = 120, + lives = 4, speed = 4, moves = {"snake_whip", "venom_bite", "poison_of_the_past"}, asset_dir = "assets/characters/Emerald Venom", @@ -17,7 +17,7 @@ return { }, { name = "Golden Radiance", - health = 85, + lives = 5, speed = 8, moves = {"solar_boom", "flashbang", "flare_frenzy"}, asset_dir = "assets/characters/Golden Radiance", @@ -25,7 +25,7 @@ return { }, { name = "Crimson Reaper", - health = 180, + lives = 2, speed = 2, moves = {"soul_slash", "deaths_reach", "phantom_step", "grim_harvest"}, asset_dir = "assets/characters/Crimson Reaper", diff --git a/assets/scripts/local2P.lua b/assets/scripts/local2P.lua index c8e0aa5..7fd2efa 100644 --- a/assets/scripts/local2P.lua +++ b/assets/scripts/local2P.lua @@ -1,42 +1,80 @@ ---@diagnostic disable: undefined-global +backgrounds = require("assets.backgrounds.backgrounds-data") + +groundTiles = { + { x = 250, y = HEIGHT - 300, width = 200, height = 30 }, + { x = WIDTH - 250 - 200, y = HEIGHT - 300, width = 200, height = 30 }, +} + function SafeInitCharacter(character, default_x, default_y) character.x = character.x or default_x character.y = character.y or default_y character.y_velocity = character.y_velocity or 1 character.current_sprite = character.asset_dir .. "/sprites/idle.png" + character.can_jump = false + character.knockback_counter = 0 + character.combo_chain = 0 + character.can_apply_knockback = false end function Setup() - SafeInitCharacter(player1Character, 250, 250) - SafeInitCharacter(player2Character, WIDTH - 250 - (250 / 2), 250) + local bgIndex = math.random(1, #backgrounds) + setBgImage(backgrounds[bgIndex]) + SafeInitCharacter(player1Character, 250, 150) + SafeInitCharacter(player2Character, WIDTH - 250 - (250 / 2), 150) end gravity = 1.2 -- POSITIVE gravity -floor_y = HEIGHT - 250 + +function DrawGroundTiles() + for _, tile in ipairs(groundTiles) do + queueRectForRender(tile.x, tile.y, tile.width, tile.height, 100, 100, 100, 255) -- gray boxes + end +end + +function IsOnGround(character) + for _, tile in ipairs(groundTiles) do + local characterFeetY = character.y + 128 + + local isWithinX = character.x + 64 > tile.x and character.x < tile.x + tile.width + local isTouchingY = characterFeetY >= tile.y and characterFeetY <= tile.y + tile.height + + if isWithinX and isTouchingY then + character.y = tile.y - 128 + return true + end + end + return false +end function HandleP1Input() - if Input.isKeyPressedOnce("W") and player1Character.y == floor_y then - player1Character.y_velocity = player1Character.jump_strength * -1.0; + if Input.isKeyPressedOnce("W") and player1Character.can_jump then + player1Character.y_velocity = player1Character.jump_strength * -1.0 + player1Character.can_jump = false end if Input.isKeyDown("D") then - player1Character.x = player1Character.x + player1Character.speed; + player1Character.x = player1Character.x + player1Character.speed end if Input.isKeyDown("A") then - player1Character.x = player1Character.x - player1Character.speed; + player1Character.x = player1Character.x - player1Character.speed + end + if Input.isKeyPressedOnce("F") then + end end function HandleP2Input() - if Input.isKeyPressedOnce("UP") and player2Character.y == floor_y then - player2Character.y_velocity = player2Character.jump_strength * -1.0; + if Input.isKeyPressedOnce("UP") and player2Character.can_jump then + player2Character.y_velocity = player2Character.jump_strength * -1.0 + player2Character.can_jump = false end if Input.isKeyDown("RIGHT") then - player2Character.x = player2Character.x + player2Character.speed; + player2Character.x = player2Character.x + player2Character.speed end if Input.isKeyDown("LEFT") then - player2Character.x = player2Character.x - player2Character.speed; + player2Character.x = player2Character.x - player2Character.speed end end @@ -45,18 +83,18 @@ function Update() player1Character.y_velocity = player1Character.y_velocity + gravity player1Character.y = player1Character.y + player1Character.y_velocity - if player1Character.y > floor_y then - player1Character.y = floor_y + if IsOnGround(player1Character) then player1Character.y_velocity = 0 + player1Character.can_jump = true end -- P2 physics player2Character.y_velocity = player2Character.y_velocity + gravity player2Character.y = player2Character.y + player2Character.y_velocity - if player2Character.y > floor_y then - player2Character.y = floor_y + if IsOnGround(player2Character) then player2Character.y_velocity = 0 + player2Character.can_jump = true end -- Render @@ -72,6 +110,42 @@ function Update() math.floor(player2Character.y) ) + local fontFile = "assets/fonts/OpenSans-Bold.ttf" + local fontSize = 24 + local text = player1Character.name + + local x = 20 + local y = 20 + + queueTextForRender(text, fontFile, x, y, fontSize, 0, 0, 0, 255) + + local text = player2Character.name + + local textWidth = getTextWidth(fontFile, fontSize, text) + local x = WIDTH - textWidth - 20 + local y = 20 + + queueTextForRender(text, fontFile, x, y, fontSize, 0, 0, 0, 255) + + local fontFile = "assets/fonts/OpenSans-MediumItalic.ttf" + local fontSize = 34 + local text = tonumber(player1Character.knockback_counter) + + local x = 40 + local y = 40 + + queueTextForRender(text, fontFile, x, y, fontSize, 0, 0, 0, 255) + + local fontFile = "assets/fonts/OpenSans-MediumItalic.ttf" + local fontSize = 34 + local text = tostring(player2Character.knockback_counter) + + local textWidth = getTextWidth(fontFile, fontSize, text) + local x = WIDTH - textWidth - 40 + + queueTextForRender(text, fontFile, x, y, fontSize, 0, 0, 0, 255) + + DrawGroundTiles() -- Input HandleP1Input() |
