summaryrefslogtreecommitdiff
path: root/objects
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-13 10:55:24 +0800
committerEltrac <hi@guhub.cn>2025-03-13 10:55:24 +0800
commitaa3d4e377fddf077e2b8cc77f17c1eefd5f97b5e (patch)
treef13c7b5caedb666c696e3cf91a1b36295b85f0c6 /objects
parent7a48e0303241ff30572028d3c8cc303c09b04fa3 (diff)
refactor: remove body:draw method
Diffstat (limited to 'objects')
-rw-r--r--objects/Body.lua30
-rw-r--r--objects/Obstacle.lua4
2 files changed, 3 insertions, 31 deletions
diff --git a/objects/Body.lua b/objects/Body.lua
index 4ca50d1..30ac165 100644
--- a/objects/Body.lua
+++ b/objects/Body.lua
@@ -15,34 +15,4 @@ function Body:new(shape, sizeA, sizeB, zoom)
return obj
end
-function Body:draw(x, y)
- if self.shape == "circle" then
- love.graphics.circle("fill", x, y, self.r)
- elseif self.shape == "rectangle" then
- love.graphics.rectangle("fill", x - self.w / 2, y - self.h / 2, self.w, self.h)
- end
-end
-
-function Body:drawSprite(spriteName, x, y, angle)
- local sprite = sprite.get(spriteName)
- local w, h = (self.shape == "circle" and self.r or self.w), (self.shape == "circle" and self.r or self.h)
-
- love.graphics.draw(sprite, x, y, angle,
- w / sprite:getWidth(),
- h / sprite:getHeight()
- )
-end
-
-function Body:drawQuad(sheet, index, x, y, angle)
- if self.shape == "circle" then
- local r = self.r
- local graphicR = r * self.zoom
- sprite.drawQuad(sheet, index, x - r, y - r, graphicR, graphicR, angle or 0)
- else
- local w, h = self.w, self.h
- local graphicW, graphicH = w * self.zoom, h * self.zoom
- sprite.drawQuad(sheet, index, x - w/2, y - h/2, graphicW, graphicH, angle or 0)
- end
-end
-
return Body
diff --git a/objects/Obstacle.lua b/objects/Obstacle.lua
index 51a1ee6..74297cd 100644
--- a/objects/Obstacle.lua
+++ b/objects/Obstacle.lua
@@ -13,7 +13,9 @@ function Obstacle:new(name, location, body)
presetLocation = (type(location) == "string" and location) or nil,
x = (type(location) == "table" and location.x) or nil,
y = (type(location) == "table" and location.y) or nil,
- body = body or Body:new("rectangle", 50, 50)
+ body = body or Body:new("rectangle", 50, 50),
+ w = 50,
+ h = 50,
}
setmetatable(obj, Obstacle)