Simple tweak: allow single line in lines
This commit is contained in:
parent
3179442942
commit
00601ed4a9
2 changed files with 29 additions and 21 deletions
8
edge.lua
8
edge.lua
|
@ -8,7 +8,7 @@ local edge_data = {
|
|||
y = 10,
|
||||
width = 80,
|
||||
height = 10,
|
||||
lines = {{'fill', {0, 10, 80, 10, 40, 0}}},
|
||||
lines = {'fill', {0, 10, 80, 10, 40, 0}},
|
||||
},
|
||||
|
||||
down = {
|
||||
|
@ -16,7 +16,7 @@ local edge_data = {
|
|||
y = 220,
|
||||
width = 80,
|
||||
height = 10,
|
||||
lines = {{'fill', {0, 0, 80, 0, 40, 10}}},
|
||||
lines = {'fill', {0, 0, 80, 0, 40, 10}},
|
||||
},
|
||||
|
||||
left = {
|
||||
|
@ -24,7 +24,7 @@ local edge_data = {
|
|||
y = 80,
|
||||
width = 10,
|
||||
height = 80,
|
||||
lines = {{'fill', {10, 0, 10, 80, 0, 40}}},
|
||||
lines = {'fill', {10, 0, 10, 80, 0, 40}},
|
||||
},
|
||||
|
||||
right = {
|
||||
|
@ -32,7 +32,7 @@ local edge_data = {
|
|||
y = 80,
|
||||
width = 10,
|
||||
height = 80,
|
||||
lines = {{'fill', {0, 0, 0, 80, 10, 40}}},
|
||||
lines = {'fill', {0, 0, 0, 80, 10, 40}},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
20
entity.lua
20
entity.lua
|
@ -27,12 +27,7 @@ function m:setpos(x, y)
|
|||
self.y = y
|
||||
end
|
||||
|
||||
function m:draw()
|
||||
love.graphics.push('all')
|
||||
love.graphics.translate(self.x, self.y)
|
||||
love.graphics.setLineWidth(3)
|
||||
|
||||
for _, l in ipairs(self.lines) do
|
||||
local function draw_line(l)
|
||||
local mode = l[1]
|
||||
local segs = l[2]
|
||||
|
||||
|
@ -50,6 +45,19 @@ function m:draw()
|
|||
else
|
||||
error(string.format("mode must be one of line or fill, not %s", mode))
|
||||
end
|
||||
end
|
||||
|
||||
function m:draw()
|
||||
love.graphics.push('all')
|
||||
love.graphics.translate(self.x, self.y)
|
||||
love.graphics.setLineWidth(3)
|
||||
|
||||
if type(self.lines[1]) == 'string' then
|
||||
draw_line(self.lines)
|
||||
else
|
||||
for _, l in ipairs(self.lines) do
|
||||
draw_line(l)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.pop()
|
||||
|
|
Loading…
Add table
Reference in a new issue