diff --git a/sonic-radiance.love/scenes/overworld/actors/player.lua b/sonic-radiance.love/scenes/overworld/actors/player.lua index 18f6edc..e20da85 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player.lua @@ -85,7 +85,7 @@ function Player:collisionResponse(col) end end if (col.other.type == "btnInput" and col.other.owner.needButton) then - if (self.keys["A"].isPressed) then + if (self.keys["A"].isPressed and (self:faceRightDirection(col.other.owner))) then col.other.owner:doAction() self.haveCollided = true self.lastCollision = col.other.owner.creationID @@ -94,6 +94,21 @@ function Player:collisionResponse(col) end end +function Player:faceRightDirection(other) + if (self.charDir == "up") then + return (self.y >= other.y + other.h) + end + if (self.charDir == "down") then + return (self.y + self.h <= other.y) + end + if (self.charDir == "left") then + return (self.x >= other.x + other.w) + end + if (self.charDir == "right") then + return (self.x + self.w <= other.x) + end +end + function Player:timerResponse(response) if (response == "changeCharacter") then self.canChangeActive = true