diff options
| author | Eltrac <hi@guhub.cn> | 2025-02-21 15:57:29 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-02-21 15:57:29 +0800 |
| commit | 960f14ad41bda85cf33dd6b63f49124606d23b93 (patch) | |
| tree | 3274e7451714d86b9b0cb39b93fa76d32aed07d4 /objects/Body.lua | |
| parent | 9f76f5ef1776321378ac522672a9835e7c6b4a54 (diff) | |
fix: drawing doors at wrong location
Diffstat (limited to 'objects/Body.lua')
| -rw-r--r-- | objects/Body.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/objects/Body.lua b/objects/Body.lua index aa5bd75..e9a4b94 100644 --- a/objects/Body.lua +++ b/objects/Body.lua @@ -38,11 +38,14 @@ function Body:collide(other, x1, y1, x2, y2) return false end -function Body:draw(x, y) +function Body:draw(x, y, offsetFix) if self.shape == "circle" then - love.graphics.circle("fill", x, y, self.r) + local offset = offsetFix and - self.r / 2 or 0 + love.graphics.circle("fill", x + offset, y + offset, self.r) elseif self.shape == "rectangle" then - love.graphics.rectangle("fill", x - self.w / 2, y - self.h / 2, self.w, self.h) + local offsetX = offsetFix and - self.w / 2 or 0 + local offsetY = offsetFix and - self.h / 2 or 0 + love.graphics.rectangle("fill", x + offsetX, y + offsetY, self.w, self.h) end end |
