-
Notifications
You must be signed in to change notification settings - Fork 0
/
brick.lua
36 lines (28 loc) · 1.1 KB
/
brick.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local Brick = Base:extend({
image = nil,
body = nil,
shape = nil,
fixture = nil,
})
function Brick:constructor(x, y)
self.image = love.graphics.newImage("assets/brick.png")
self.body = love.physics.newBody(world, x, y, "static")
self.shape = love.physics.newRectangleShape(self.image:getWidth(),
self.image:getHeight())
self.fixture = love.physics.newFixture(self.body, self.shape)
self.fixture:setFriction(0.0)
self.fixture:setUserData("Brick")
print(self.fixture:getBoundingBox())
print(self.body:getX(), self.body:getY())
end
function Brick:draw(dt)
if not self.fixture:isDestroyed() then
--love.graphics.draw(self.image, self.body:getX() - (self.image:getHeight() / 2),
-- self.body:getY() - (self.image:getHeight() / 2))
x, y = self.fixture:getBoundingBox()
love.graphics.draw(self.image, x, y)
--love.graphics.rectangle('fill', self.body:getX(), self.body:getY(),
--self.image:getWidth(), self.image:getHeight())
end
end
return Brick