fix(world): separate getting data from the internal and advertised view
Use two functions instead of just one, one showing the actual dimensions of the internal "cam" (basically, the whole screen), and one showing the advertised displaced camera. Fixes #16
This commit is contained in:
parent
80072d285a
commit
3ced2dbef4
3 changed files with 22 additions and 8 deletions
|
@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- **examples:** Add missing HUD example for one-player plateformer
|
- **examples:** Add missing HUD example for one-player plateformer
|
||||||
|
|
||||||
|
- **world:** Separate getting dimensions of the internal and advertised view.
|
||||||
|
|
||||||
## 0.5.0 - 2019-06-16
|
## 0.5.0 - 2019-06-16
|
||||||
|
|
||||||
- Meta: Add a Code of Conduct
|
- Meta: Add a Code of Conduct
|
||||||
|
|
|
@ -413,7 +413,7 @@ function BaseWorld:drawMap(id)
|
||||||
if id ~= nil then
|
if id ~= nil then
|
||||||
-- Du à la manière dont fonctionne STI, on est obligé de récupérer les info
|
-- Du à la manière dont fonctionne STI, on est obligé de récupérer les info
|
||||||
-- de position de camera pour afficher la carte par rapport à ces infos
|
-- de position de camera pour afficher la carte par rapport à ces infos
|
||||||
tx, ty = self.cameras:getViewCoordinate(id)
|
tx, ty = self.cameras:getInternalCamCoordinate(id)
|
||||||
scale = self.cameras:getViewScale(id) or 1
|
scale = self.cameras:getViewScale(id) or 1
|
||||||
local vx, vy = self.cameras:getOnScreenViewRelativePosition(id)
|
local vx, vy = self.cameras:getOnScreenViewRelativePosition(id)
|
||||||
tx = math.floor(tx - math.abs(vx))
|
tx = math.floor(tx - math.abs(vx))
|
||||||
|
|
|
@ -194,15 +194,27 @@ function CameraSystem:detachView(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CameraSystem:getViewCoordinate(id)
|
function CameraSystem:getViewCoordinate(id)
|
||||||
local cam = self:getViewCam(id)
|
local view = self:getView(id)
|
||||||
|
|
||||||
local camx, camy, camw, camh
|
local viewx, viewy, vieww, viewh
|
||||||
camx = cam.x - (self.views.width/2)
|
viewx = view.pos.x - (self.views.width/2)
|
||||||
camy = cam.y - (self.views.height/2)
|
viewy = view.pos.y - (self.views.height/2)
|
||||||
|
|
||||||
camw = self.views.width
|
vieww = self.views.width
|
||||||
camh = self.views.height
|
viewh = self.views.height
|
||||||
return camx, camy, camw, camh
|
return viewx, viewy, vieww, viewh
|
||||||
|
end
|
||||||
|
|
||||||
|
function CameraSystem:getInternalCamCoordinate(id)
|
||||||
|
local view = self:getView(id)
|
||||||
|
local cam = self:getViewCam(id)
|
||||||
|
|
||||||
|
local viewx, viewy, vieww, viewh
|
||||||
|
viewx = cam.x - (self.views.width/2)
|
||||||
|
viewy = cam.y - (self.views.height/2)
|
||||||
|
|
||||||
|
vieww, viewh = core.screen:getDimensions()
|
||||||
|
return viewx, viewy, vieww, viewh
|
||||||
end
|
end
|
||||||
|
|
||||||
function CameraSystem:getOnScreenViewCoordinate(id)
|
function CameraSystem:getOnScreenViewCoordinate(id)
|
||||||
|
|
Loading…
Reference in a new issue