summaryrefslogtreecommitdiffhomepage
path: root/not/World.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-13 10:19:02 +0200
committerAki <nthirtyone@gmail.com>2017-09-13 10:19:02 +0200
commite8bd3dfd8031930fa3f0169300620e5a0400995d (patch)
tree931077a945dbd5d1ddb113972f8f5146fa5a4847 /not/World.lua
parent2a0cef0fba687e03fd322ac73c511bbb12b1e31c (diff)
downloadroflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.zip
roflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.tar.gz
roflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.tar.bz2
Another attempt to fix real scaling bug
Diffstat (limited to 'not/World.lua')
-rw-r--r--not/World.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/not/World.lua b/not/World.lua
index e3b7695..0a560fb 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -22,12 +22,12 @@ function World:new (map, nauts)
self.entities = {}
self.map = map
+ self.camera = Camera(self.map.center.x, self.map.center.y, self)
+
self:initLayers()
self:buildMap()
self:spawnNauts(nauts)
- self.camera = Camera(self.map.center.x, self.map.center.y, self)
-
musicPlayer:play(self.map.theme)
end
@@ -62,10 +62,13 @@ end
-- Layers are drawn in reverse order, meaning that `instance.layers[1]` will be on the top.
-- Calling `instance.layers` will return iterator.
function World:initLayers ()
- local width, height = love.graphics.getDimensions()
self.layers = setmetatable({}, {__call = layersIterator})
self.layers.n = 0
- self.layers.rays = self:addLayer(320, 180, 0, 1)
+
+ local width, height = self.camera:getViewSize()
+ self.layers.rays = self:addLayer(width, height, 0, 1)
+
+ local width, height = love.graphics.getDimensions()
self.layers.tags = self:addLayer(width, height)
self.layers.platforms = self:addLayer(width, height)
self.layers.effects = self:addLayer(width, height)
@@ -100,8 +103,13 @@ function World:buildMap ()
height = height * getScale()
end
bg.layer = self:addLayer(width, height, op.ratio, getRealScale())
- print("ayyy", getScale(), getRealScale())
- print("lmao", x, y)
+ bg.layer.renderToWith = function (self, camera, func, ...)
+ camera:push()
+ camera:scale(self.scale)
+ camera:translateReal(self.ratio)
+ self:renderTo(func, ...)
+ camera:pop()
+ end
bg.layer.draw = function (self)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.draw(self.canvas)