-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrick.lua
More file actions
45 lines (37 loc) · 866 Bytes
/
brick.lua
File metadata and controls
45 lines (37 loc) · 866 Bytes
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
37
38
39
40
41
42
43
44
45
local brick = {}
function brick:collide(brk, ball)
env.balls.dx = brk.shape._polygon.centroid.x - ball.shape._center.x
end
function brick:load()
brick.table = {}
return brick
end
function brick:basicBrick()
return {
x = love.window.getWidth() / 2,
y = love.window.getHeight() / 2,
width = 30,
height = 10,
orientation = 0,
callback = nil
}
end
function brick:new(param)
local newBrick = brick:basicBrick()
if param ~= nil then
for index, value in pairs(param) do
newBrick[index] = value
end
end
newBrick.shape = env.collider:addRectangle(newBrick.x, newBrick.y, newBrick.width, newBrick.height)
table.insert(brick.table, newBrick)
end
function brick:update(dt)
end
function brick:draw()
love.graphics.setColor(255, 255, 255, 255)
for index, brk in ipairs(brick.table) do
brk.shape:draw('fill')
end
end
return brick