scenes/level: don't have direct access to camera view
This commit is contained in:
parent
8b6e3ce544
commit
c40a4c1678
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue