From 3bd966953dc68a7d7b6ba5343b6983233c0e4bc0 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 8 Nov 2024 09:42:44 +0100 Subject: [PATCH] =?UTF-8?q?fix(physics):=20amelioration=20gestion=20coordo?= =?UTF-8?q?nn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/scenes/world/actors/init.lua | 5 ++--- framework/scenes/world/actors/physics/init.lua | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/framework/scenes/world/actors/init.lua b/framework/scenes/world/actors/init.lua index 194868c..093b1cc 100644 --- a/framework/scenes/world/actors/init.lua +++ b/framework/scenes/world/actors/init.lua @@ -80,13 +80,12 @@ function Actor:drawShadow() if (self.world.type ~= "3D" and self.world.drawShadow ~= true) then return end - local shadowZ = self:getGroundZ() - if (shadowZ == nil) then + if (self.zGround == nil) then return end local r, g, b, a = love.graphics.getColor( ) - local x, y = self.position.x + (self.dimensions.w / 2), self.position.y + (3 * self.dimensions.h / 4) - shadowZ + local x, y = self.position.x + (self.dimensions.w / 2), self.position.y + (3 * self.dimensions.h / 4) - self.zGround love.graphics.setColor(0, 0, 0, .3) love.graphics.ellipse( "fill", math.floor(x), math.floor(y), self.dimensions.w / 2, self.dimensions.w / 4 ) love.graphics.setColor(r, g, b, a) diff --git a/framework/scenes/world/actors/physics/init.lua b/framework/scenes/world/actors/physics/init.lua index bbb5391..e5e2f70 100644 --- a/framework/scenes/world/actors/physics/init.lua +++ b/framework/scenes/world/actors/physics/init.lua @@ -141,6 +141,11 @@ function Physics:applyMovement(dt) -- Les autres hitboxes traverses tout self:applyHitboxesCollisions(function(item, other) return "cross" end) + + if (self.visual ~= nil) then + self:getGroundZ() + self.world:updateShape(self) + end end function Physics:move(position) @@ -148,9 +153,6 @@ function Physics:move(position) if (self.isDestroyed == false) then self.position, cols, colNumber = self.mainHitbox:checkCollisionAtPoint(position, self.filter) self.mainHitbox:updatePosition() - if (self.visual ~= nil) then - self.world:updateShape(self) - end end return self.position, cols, colNumber @@ -202,7 +204,9 @@ function Physics:getGroundZ() end end end - return z + if (z ~= nil) then + self.zGround = math.floor(z) + end end function Physics:_applyCollisionResponses(col)