From 97b3bcf80f191f44f85fc8347dccbdec2f666fc6 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 28 Dec 2019 14:17:58 +0100 Subject: [PATCH] feat: make some camera elements world-dependant --- sonic-bluestreak.love/game/modules/world/actors/player.lua | 2 +- sonic-bluestreak.love/game/modules/world/parent.lua | 4 ++++ sonic-bluestreak.love/game/modules/world/shoot.lua | 4 ++++ sonic-bluestreak.love/scenes/test_scene/init.lua | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sonic-bluestreak.love/game/modules/world/actors/player.lua b/sonic-bluestreak.love/game/modules/world/actors/player.lua index 47b9e7b..5627ebd 100644 --- a/sonic-bluestreak.love/game/modules/world/actors/player.lua +++ b/sonic-bluestreak.love/game/modules/world/actors/player.lua @@ -83,7 +83,7 @@ end function Player:getViewCenter() local x, y = Player.super.getViewCenter(self) - return x, y-16 + return self.world:getViewCenter(x, y) end function Player:draw() diff --git a/sonic-bluestreak.love/game/modules/world/parent.lua b/sonic-bluestreak.love/game/modules/world/parent.lua index 368ded7..0fb7b3b 100644 --- a/sonic-bluestreak.love/game/modules/world/parent.lua +++ b/sonic-bluestreak.love/game/modules/world/parent.lua @@ -30,6 +30,10 @@ function ParentWorld:addInvisibleWalls() self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000) end +function ParentWorld:getViewCenter(x, y) + return x, y-16 +end + function ParentWorld:draw(dt) self:drawBackgroundColor() local camNumber = self.cameras:getViewNumber() diff --git a/sonic-bluestreak.love/game/modules/world/shoot.lua b/sonic-bluestreak.love/game/modules/world/shoot.lua index 6039269..b3f99d7 100644 --- a/sonic-bluestreak.love/game/modules/world/shoot.lua +++ b/sonic-bluestreak.love/game/modules/world/shoot.lua @@ -10,6 +10,10 @@ function ShootWorld:new(scene, mapname) self.mapname = mapname end +function ShootWorld:getViewCenter(x, y) + return x+128, y-16 +end + function ShootWorld:createMapController() self.customMap.Shoot(self, self.maptype, self.mapname) self.cameras:lockY(10) diff --git a/sonic-bluestreak.love/scenes/test_scene/init.lua b/sonic-bluestreak.love/scenes/test_scene/init.lua index efb7df4..39c08b5 100644 --- a/sonic-bluestreak.love/scenes/test_scene/init.lua +++ b/sonic-bluestreak.love/scenes/test_scene/init.lua @@ -35,9 +35,9 @@ function MovePlayer:new(playerNumber, cameraMode) MovePlayer.super.new(self) self.assets:batchImport("scenes.test_scene.assets") - --ShootWorld(self, "coast") + ShootWorld(self, "coast") --BattleWorld(self, "ebeach") - TestWorld(self) + --TestWorld(self) self.world:setPlayerNumber(playerNumber) self.world.cameras:setMode(cameraMode)