summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-11 22:41:43 +0200
committerAki <nthirtyone@gmail.com>2017-09-11 22:41:43 +0200
commit947fb92b43cbe191123c376bb62b5489c19b40be (patch)
tree9fb32492755904b92d2bc0063eeb9faf846a5f58 /not
parent9544249897d47fa40fa833b8e57fda1c54d8e26d (diff)
downloadroflnauts-947fb92b43cbe191123c376bb62b5489c19b40be.zip
roflnauts-947fb92b43cbe191123c376bb62b5489c19b40be.tar.gz
roflnauts-947fb92b43cbe191123c376bb62b5489c19b40be.tar.bz2
Tags moved to a Layer
More layering and drawing clean-ups
Diffstat (limited to 'not')
-rw-r--r--not/World.lua35
1 files changed, 15 insertions, 20 deletions
diff --git a/not/World.lua b/not/World.lua
index 88b15cc..b386598 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -23,14 +23,10 @@ function World:new (map, nauts)
-- TODO: Clean layering. This is prototype. Seriously don't use it in production.
self.entities = {}
local width, height = love.graphics.getDimensions()
- self.layers = {
- Layer(width, height), -- back
- Layer(width, height), -- cloud
- Layer(width, height), -- deco
- Layer(width, height), -- nauts
- Layer(width, height), -- plats
- Layer(width, height), -- front
- }
+ self.layers = {}
+ for i=1,7 do
+ table.insert(self.layers, Layer(width, height))
+ end
self.layers[1].ratio = 0
self.map = map
@@ -130,7 +126,7 @@ end
function World:createRay (naut)
local r = Ray(naut, self)
table.insert(self.entities, r)
- r.layer = self.layers[6]
+ r.layer = self.layers[7]
return r
end
@@ -259,25 +255,23 @@ function World:draw ()
entity.layer:renderTo(entity.draw, entity, 0, 0, scale, debug) -- TODO: Offsets are passed as zeroes in World@draw for compatibility reasons. Remove them.
self.camera:pop()
end
+ if entity.drawTag then
+ self.camera:translate()
+ self.layers[6]:renderTo(entity.drawTag, entity, 0, 0, scale) -- TODO: Offsets passed. See `World@draw`.
+ self.camera:pop()
+ end
end
- love.graphics.setCanvas()
-
for _,layer in ipairs(self.layers) do
layer:draw()
layer:clear()
end
-
- -- TODO: Just move heroes' tags to front layer.
- self.camera:translate()
- for _,naut in pairs(self:getNautsAlive()) do
- naut:drawTag(0, 0, scale) -- TODO: Offsets passed. See `World@draw`.
- end
if debug then
local center = self.map.center
local ax, ay, bx, by = self.camera:getBoundariesScaled()
-
+
+ self.camera:translate()
love.graphics.setLineWidth(1)
love.graphics.setLineStyle("rough")
@@ -288,9 +282,10 @@ function World:draw ()
love.graphics.setColor(200,200,200)
love.graphics.line(ax,0,bx,0)
love.graphics.line(0,ay,0,by)
- end
- self.camera:pop()
+ self.camera:pop()
+ end
+
for _,naut in pairs(self:getNautsAll()) do
-- I have no idea where to place them T_T
-- let's do: bottom-left, bottom-right, top-left, top-right