aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Cholewiński <harry666t@gmail.com>2016-03-01 23:36:58 +0100
committerKamil Cholewiński <harry666t@gmail.com>2016-03-01 23:36:58 +0100
commit944672d843f76d4ae09c50e25b07870568253d49 (patch)
tree0302ef6051f5b4dcc362f8463cd805387ad0626e
parentf577a3459d99d3d8dd883726055edc81442a4fcb (diff)
downloadkittenlanding-944672d843f76d4ae09c50e25b07870568253d49.zip
kittenlanding-944672d843f76d4ae09c50e25b07870568253d49.tar.gz
kittenlanding-944672d843f76d4ae09c50e25b07870568253d49.tar.bz2
move draw_shapes to Painters
-rw-r--r--game/Building.lua21
-rw-r--r--game/Painters.lua17
2 files changed, 19 insertions, 19 deletions
diff --git a/game/Building.lua b/game/Building.lua
index 492e9d0..8825e57 100644
--- a/game/Building.lua
+++ b/game/Building.lua
@@ -43,23 +43,6 @@ function Building:init(args)
}
end
-local function draw_shapes(shapes, color)
- local fake_body = {
- getWorldPoints = function(self, ...) return ... end
- }
- for _, data in ipairs(shapes) do
- local shape = data.shape
- local painter = assert(Painters[shape:getType()],
- "No painter for shape " .. shape:getType())
- if data.def.data and data.def.data.color then
- love.graphics.setColor(data.def.data.color)
- else
- love.graphics.setColor(color)
- end
- painter(fake_body, shape, data.def.data)
- end
-end
-
function Building:draw()
local w, h = love.graphics.getDimensions()
local ww, wh = 80, 140 -- window size
@@ -107,7 +90,7 @@ function Building:draw()
if deco == "kitten" then
love.graphics.push()
love.graphics.translate(ww / 2, wh - 20)
- draw_shapes(self.kitten_head_shapes, looking_kitten)
+ Painters.draw_shapes(self.kitten_head_shapes, looking_kitten)
love.graphics.pop()
end
@@ -127,7 +110,7 @@ function Building:draw()
love.graphics.push()
love.graphics.translate(200 * i,
self.spectator_y[(i % 5) + 1] - 2*fh)
- draw_shapes(self.kitten_shapes, looking_kitten)
+ Painters.draw_shapes(self.kitten_shapes, looking_kitten)
love.graphics.pop()
end
diff --git a/game/Painters.lua b/game/Painters.lua
index 6b04db7..e30ed14 100644
--- a/game/Painters.lua
+++ b/game/Painters.lua
@@ -19,4 +19,21 @@ function Painters.edge(body, shape)
love.graphics.line(body:getWorldPoints(shape:getPoints()))
end
+function Painters.draw_shapes(shapes, color)
+ local fake_body = {
+ getWorldPoints = function(self, ...) return ... end
+ }
+ for _, data in ipairs(shapes) do
+ local shape = data.shape
+ local painter = assert(Painters[shape:getType()],
+ "No painter for shape " .. shape:getType())
+ if data.def.data and data.def.data.color then
+ love.graphics.setColor(data.def.data.color)
+ else
+ love.graphics.setColor(color)
+ end
+ painter(fake_body, shape, data.def.data)
+ end
+end
+
return Painters