This commit is contained in:
lustlion 2022-02-26 21:19:54 +01:00
parent e9754dc1dd
commit 8bad3894dc
3 changed files with 150 additions and 61 deletions

View File

@ -91,7 +91,7 @@ function Player:Smart()
self.move_x = self.moveSpeed self.move_x = self.moveSpeed
end end
-- jump if on ground (coyotevalue) -- jump if on ground (coyotevalue) or if on wall (wallHit)
if Keybind:CheckDown(Keybind.move.jump) then if Keybind:CheckDown(Keybind.move.jump) then
if self.coyoteValue > 0 then if self.coyoteValue > 0 then
self.vel.y = -self.jumpImpulse self.vel.y = -self.jumpImpulse

View File

@ -0,0 +1,89 @@
From 1d8685c91e64daedfef9607ec122c3de05be36e5 Mon Sep 17 00:00:00 2001
From: binarycat <binarycat64@protonmail.com>
Date: Sat, 26 Feb 2022 15:12:25 -0500
Subject: [PATCH] walljumps
---
code/debug.lua | 1 +
code/entities/player.lua | 12 ++++++++++++
code/entity.lua | 3 ++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/code/debug.lua b/code/debug.lua
index 5a9e094..68c61cf 100644
--- a/code/debug.lua
+++ b/code/debug.lua
@@ -22,6 +22,7 @@ function DebugUI()
end
end
-- player isOnGroundCheck
+ --love.graphics.main_Player
love.graphics.setColor(1,0,0)
end
diff --git a/code/entities/player.lua b/code/entities/player.lua
index ea2d811..824cc25 100644
--- a/code/entities/player.lua
+++ b/code/entities/player.lua
@@ -14,6 +14,8 @@ function Player:New(x,y)
o.jumpImpulse = 3.5 -- gameworld pixels
+ self.wallJumpImpulse = { x = 2.5, y = 3.5 }
+
o.coyoteAmount = 5 -- int
o.coyoteValue = 5 -- frames
@@ -46,6 +48,7 @@ function Player:New(x,y)
o.canFall = true
o.canFriction = true
o.maskType = animation.moth_mask
+ o.wallHit = 0
o.anchorRespawn = {
x = o.pos.x,
@@ -93,6 +96,9 @@ function Player:Smart()
if self.coyoteValue > 0 then
self.vel.y = -self.jumpImpulse
self.coyoteValue = 0
+ elseif self.wallHit ~= 0 then
+ self.vel.y = -self.wallJumpImpulse.y
+ self.vel.x = -self.wallJumpImpulse.x * self.wallHit
end
end
end
@@ -233,7 +239,9 @@ function Player:DoPhysics()
-- horizontal collision
if not self:isCollidingAt(self.pos.x + self.vel.x + self.move_x, self.pos.y, LoadedObjects.Collisions) then
self.pos.x = self.pos.x + self.vel.x + self.move_x
+ self.wallHit = 0
else
+ self.wallHit = math.sign(self.vel.x + self.move_x)
self.vel.x = 0
end
@@ -313,3 +321,7 @@ function Player:Unhook()
self.isHooked = false
self.hookAnchor = nil
end
+
+function Player:Debug()
+ love.graphics.print("wallHit: "..self.wallHit)
+end
diff --git a/code/entity.lua b/code/entity.lua
index 9bb582f..b43df21 100644
--- a/code/entity.lua
+++ b/code/entity.lua
@@ -158,7 +158,8 @@ function Entity:getBoundingBox(animation,top,left,bottom,right)
self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom
end
--- returns true if theres a collision at that point. also marks collisioned tile as collision true
+-- checks if the the reciever would collide with an object if it was positioned at the given point.
+-- also marks collisioned tile as collision true
function Entity:isCollidingAt(x,y,object)
for _, collision in pairs(object) do
if collision.disable then
--
2.35.1

View File

@ -1,69 +1,69 @@
(*) Ideas (*) Ideas
( ) DO FLIES ( ) DO FLIES
( ) DO UI ( ) DO UI
( ) DO DAMAGE TO PLAYER ( ) DO DAMAGE TO PLAYER
( ) Visual design ( ) Visual design
(~) Multicolor palette depending on area, with 3 main colors (~) Multicolor palette depending on area, with 3 main colors
(X) Library: Gold #fed100 (X) Library: Gold #fed100
( ) ( )
( ) Dialog ( ) Dialog
( ) Fonts ( ) Fonts
( ) Characters ( ) Characters
( ) Level design ( ) Level design
( ) Enemy design ( ) Enemy design
( ) Gameplay design ( ) Gameplay design
( ) Level design ( ) Level design
( ) Mechanic design ( ) Mechanic design
(X) Swing hook (X) Swing hook
( ) Entity design ( ) Entity design
(~) FAIRY (~) FAIRY
(X) basic movement (X) basic movement
(X) Fairy particles~~ (X) Fairy particles~~
( ) more intelligent movement ( ) more intelligent movement
( ) avoid getting stuck to walls ( ) avoid getting stuck to walls
( ) Playtest tools ( ) Playtest tools
( ) Technical design ( ) Technical design
(?) Input (?) Input
(X) ADDED KEYBINDS (X) ADDED KEYBINDS
( ) ( )
(?) Draw (?) Draw
(X) REHANDLE ANIMATIONS (X) REHANDLE ANIMATIONS
(X) MAKE LIGHTING SYSTEM (X) MAKE LIGHTING SYSTEM
(X) Pixel perfect entity drawing (X) Pixel perfect entity drawing
( ) Pixel perfect lights ( ) Pixel perfect lights
(?) Player (?) Player
(X) MASKS FUNCTIONALITY (X) MASKS FUNCTIONALITY
( ) ( )
(?) Physics (?) Physics
(X) MAKE PHYSICS CONSISTENT (X) MAKE PHYSICS CONSISTENT
(X) MAKE HITBOXES (X) MAKE HITBOXES
(X) PHYSICS BY FRAME (X) PHYSICS BY FRAME
(X) DEACTIVATE ARROWS WHEN STUCK (X) DEACTIVATE ARROWS WHEN STUCK
( ) ( )
(~) Dialog (~) Dialog
(X) Object and Basics (X) Object and Basics
( ) Fix font and align problems ( ) Fix font and align problems
( ) Implement portrait ( ) Implement portrait
(X) Translating framework (X) Translating framework
( ) Debug tools ( ) Debug tools
( ) Audio and BGM ( ) Audio and BGM
(~) REMAKE LEVEL EDITOR (~) REMAKE LEVEL EDITOR
(~) ADD WAY TO EDIT A LEVEL (EDITOR MODE) (~) ADD WAY TO EDIT A LEVEL (EDITOR MODE)
(X) SHOW PALETTE (X) SHOW PALETTE
(X) PICK UP TILE FROM PALETTE (X) PICK UP TILE FROM PALETTE
(X) PLACE PICKED UP TILE (X) PLACE PICKED UP TILE
( ) WAY TO INSERT ENTITIES IN THE LEVEL ( ) WAY TO INSERT ENTITIES IN THE LEVEL
(X) ADD WAY TO SAVE A LEVEL (X) ADD WAY TO SAVE A LEVEL
( ) Narrative design ( ) Narrative design
( ) Dialog ( ) Dialog
( ) Characters ( ) Characters
( ) Area design ( ) Area design
( ) Translations ( ) Translations
( ) SPA "es_ES" ( ) SPA "es_ES"
( ) ENG "en_UK" ( ) ENG "en_UK"
( ) CAT "ca_ES" ( ) CAT "ca_ES"
( ) HEON "Myrheonian" ( ) HEON "Myrheonian"