scenes/level: don't have direct access to camera view

This commit is contained in:
Kazhnuz 2019-03-03 14:04:16 +01:00
parent 8b6e3ce544
commit c40a4c1678
5 changed files with 9 additions and 6 deletions

View File

@ -172,13 +172,15 @@ function Level:drawEntities()
end
function Level:drawMap()
local tx = self.camera.x - 424 / 2
local ty = self.camera.y - 240 / 2
local tx, ty = self:getCameraCoord()
local scale = self:getCameraScale()
local tx = tx
local ty = ty
tx = math.floor(tx)
ty = math.floor(ty)
self.map:draw(-tx, -ty, self.camera.scale, self.camera.scale)
self.map:draw(-tx, -ty, scale, scale)
end
function Level:drawBackgroundColor()

View File

@ -34,7 +34,7 @@ function Bullet:update(dt)
self.life = 1
local localx, localy = currentLevel:cameraCoords(self.x, self.y)
local localx, localy = self.camera:cameraCoords(self.x, self.y)
if (localx < 0) or (localx > 480) or (localy < 0) or (localy > (272)) or (self.xsp == 0) then
self:destroy()
end

View File

@ -35,7 +35,7 @@ function Debris:update(dt)
self.life = 1
local localx, localy = self.level:cameraCoords(self.x, self.y)
local localx, localy = self.camera:cameraCoords(self.x, self.y)
if (localx < 0) or (localx > 480) or (localy < 0) or (localy > (272)) or (self.xsp == 0) then
self:destroy()
end

View File

@ -10,6 +10,7 @@ end
function Entity:initPhysics(level, collType, x, y, w, h)
self.level = level
self.world = level
self.camera = level
self.obj = self.world.obj
self.collType = collType

View File

@ -43,7 +43,7 @@ function Weapon:update(dt)
self.life = 1
local localx, localy = self.level:cameraCoords(self.x, self.y)
local localx, localy = self.camera:cameraCoords(self.x, self.y)
if (localx < 0) or (localx > 480) or (localy < 0) or (localy > (272)) then
self:destroy()
end