diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-13 10:37:23 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-13 10:37:23 +0800 |
| commit | 7a48e0303241ff30572028d3c8cc303c09b04fa3 (patch) | |
| tree | 0c34d16c0b90dad6e4e6fd405f0612e430270679 /objects | |
| parent | 9dd4df6d6ce0a23cf64daae17af6726caf0c206b (diff) | |
chore: remove unused method
Diffstat (limited to 'objects')
| -rw-r--r-- | objects/Body.lua | 24 | ||||
| -rw-r--r-- | objects/Player.lua | 24 |
2 files changed, 0 insertions, 48 deletions
diff --git a/objects/Body.lua b/objects/Body.lua index d5a4e58..4ca50d1 100644 --- a/objects/Body.lua +++ b/objects/Body.lua @@ -15,30 +15,6 @@ function Body:new(shape, sizeA, sizeB, zoom) return obj end -function Body:collide(other, x1, y1, x2, y2) - if self.shape == "circle" and other.shape == "circle" then - -- circle to circle - local dx = x2 - x1 - local dy = y2 - y1 - local distance = math.sqrt(dx * dx + dy * dy) - return distance < (self.r + other.r) - elseif self.shape == "rectangle" and other.shape == "rectangle" then - -- rect to rect - return x1 < x2 + other.w and x1 + self.w > x2 and y1 < y2 + other.h and y1 + self.h > y2 - elseif self.shape == "circle" and other.shape == "rectangle" then - -- circle to rect - local closestX = math.max(x2, math.min(x1, x2 + other.w)) - local closestY = math.max(y2, math.min(y1, y2 + other.h)) - local dx = x1 - closestX - local dy = y1 - closestY - return (dx * dx + dy * dy) < (self.r * self.r) - elseif self.shape == "rectangle" and other.shape == "circle" then - return other:collide(self, x2, y2, x1, y1) - end - - return false -end - function Body:draw(x, y) if self.shape == "circle" then love.graphics.circle("fill", x, y, self.r) diff --git a/objects/Player.lua b/objects/Player.lua index 51de42d..44f2e5d 100644 --- a/objects/Player.lua +++ b/objects/Player.lua @@ -117,30 +117,6 @@ function Player:update(dt) end self.frameTimer:update(dt) - - -- player enters door - -- for _, door in pairs(G.currentRoom.doors) do - -- local entersDoor = door.body:collide(self.body, door.x, door.y, self.x, self.y) and - -- G.currentRoom.isCleared - -- if door ~= false and entersDoor then - -- map.switchRoom(door.to) - - -- -- update player position after entering a new room - -- local doorH, doorW, playerR = door.body.h, door.body.w, self.body.r - -- local roomX, roomY, roomW, roomH = G.currentRoom:getX(), G.currentRoom:getY(), G.currentRoom:getWidth(), G.currentRoom:getHeight() - -- if door.location == Direction.LEFT then - -- self:setX(roomX + roomW - playerR - doorW) - -- elseif door.location == Direction.RIGHT then - -- self:setX(roomX + playerR + doorW) - -- elseif door.location == Direction.TOP then - -- self:setY(roomY + roomH - playerR - doorH) - -- elseif door.location == Direction.BOTTOM then - -- self:setY(roomY + playerR + doorH) - -- end - - -- break - -- end - -- end end return Player |
