Merge branch '0.5.1' of game-projects/gamecore into 0.5.x
This commit is contained in:
commit
79c79d9613
4 changed files with 55 additions and 23 deletions
|
@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### 0.5.1 - 2019-06-21
|
||||||
|
|
||||||
|
- **examples:** Add missing HUD example for one-player plateformer
|
||||||
|
|
||||||
|
- **world:** Separate getting dimensions of the internal and advertised view.
|
||||||
|
|
||||||
|
- **world:** use right camera internal coordinate
|
||||||
|
|
||||||
## 0.5.0 - 2019-06-16
|
## 0.5.0 - 2019-06-16
|
||||||
|
|
||||||
- Meta: Add a Code of Conduct
|
- Meta: Add a Code of Conduct
|
||||||
|
|
|
@ -66,5 +66,8 @@ function Player:collisionResponse(collision)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:drawHUD(id)
|
||||||
|
love.graphics.print(id .. " test", 4, 4)
|
||||||
|
end
|
||||||
|
|
||||||
return Player
|
return Player
|
||||||
|
|
|
@ -384,6 +384,10 @@ function BaseWorld:draw(dt)
|
||||||
self.cameras:detachView(i)
|
self.cameras:detachView(i)
|
||||||
self.cameras:drawHUD(i)
|
self.cameras:drawHUD(i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i=1, camNumber do
|
||||||
|
self.cameras:drawDebugViewBox(i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -413,7 +417,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))
|
||||||
|
|
|
@ -73,19 +73,19 @@ function CameraSystem:initViews()
|
||||||
|
|
||||||
self.views.posList.multi[1] = {}
|
self.views.posList.multi[1] = {}
|
||||||
self.views.posList.multi[1].x = -(self.views.basewidth /4)
|
self.views.posList.multi[1].x = -(self.views.basewidth /4)
|
||||||
self.views.posList.multi[1].y = (self.views.baseheight/4)
|
self.views.posList.multi[1].y = -(self.views.baseheight/4)
|
||||||
|
|
||||||
self.views.posList.multi[2] = {}
|
self.views.posList.multi[2] = {}
|
||||||
self.views.posList.multi[2].x = (self.views.basewidth /4)
|
self.views.posList.multi[2].x = (self.views.basewidth /4)
|
||||||
self.views.posList.multi[2].y = (self.views.baseheight/4)
|
self.views.posList.multi[2].y = -(self.views.baseheight/4)
|
||||||
|
|
||||||
self.views.posList.multi[3] = {}
|
self.views.posList.multi[3] = {}
|
||||||
self.views.posList.multi[3].x = -(self.views.basewidth /4)
|
self.views.posList.multi[3].x = -(self.views.basewidth /4)
|
||||||
self.views.posList.multi[3].y = -(self.views.baseheight/4)
|
self.views.posList.multi[3].y = (self.views.baseheight/4)
|
||||||
|
|
||||||
self.views.posList.multi[4] = {}
|
self.views.posList.multi[4] = {}
|
||||||
self.views.posList.multi[4].x = (self.views.basewidth /4)
|
self.views.posList.multi[4].x = (self.views.basewidth /4)
|
||||||
self.views.posList.multi[4].y = -(self.views.baseheight/4)
|
self.views.posList.multi[4].y = (self.views.baseheight/4)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- INFO FUNCTIONS
|
-- INFO FUNCTIONS
|
||||||
|
@ -180,6 +180,14 @@ function CameraSystem:attachView(id)
|
||||||
|
|
||||||
local viewx, viewy, vieww, viewh = self:getOnScreenViewCoordinate(id)
|
local viewx, viewy, vieww, viewh = self:getOnScreenViewCoordinate(id)
|
||||||
cam:attach()
|
cam:attach()
|
||||||
|
|
||||||
|
if (self:getViewNumber() > 2) or (self:getViewNumber() == 2 and SPLITSCREEN_ISVERTICAL) then
|
||||||
|
-- FIXME: it's an ugly workaround that need to be fixed. For an unkown
|
||||||
|
-- reason, the scissoring is wrong in and only in this function and only
|
||||||
|
-- when we have vertical split. Thus, we need to substract viewy to viewy
|
||||||
|
viewy = viewh - viewy
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -194,15 +202,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)
|
||||||
|
@ -287,11 +307,7 @@ function CameraSystem:computeCamPosition(id)
|
||||||
local realy = self.views.list[id].pos.y
|
local realy = self.views.list[id].pos.y
|
||||||
|
|
||||||
self.views.list[id].cam.x = realx - decalx
|
self.views.list[id].cam.x = realx - decalx
|
||||||
self.views.list[id].cam.y = realy + decaly
|
self.views.list[id].cam.y = realy - decaly
|
||||||
-- FIXME: this workaround certainly will cause some problem but that's the only
|
|
||||||
-- solution we seem to have right now
|
|
||||||
-- We invert the y decalage for the camera in order to work around a problem
|
|
||||||
-- that invert the y between it and the clipping.
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CameraSystem:followActor(id)
|
function CameraSystem:followActor(id)
|
||||||
|
@ -315,9 +331,10 @@ function CameraSystem:drawDebugViewBox(id)
|
||||||
local xx, yy = self:getOnScreenViewCenter(id)
|
local xx, yy = self:getOnScreenViewCenter(id)
|
||||||
love.graphics.line(xx-3, yy, xx+3, yy)
|
love.graphics.line(xx-3, yy, xx+3, yy)
|
||||||
love.graphics.line(xx, yy-3, xx, yy+3)
|
love.graphics.line(xx, yy-3, xx, yy+3)
|
||||||
local string = id .. " x:" .. viewx .. " y:" .. viewy
|
|
||||||
|
local xx, yy = self:getInternalCamCoordinate(id)
|
||||||
|
local string = id .. " x:" .. xx .. " y:" .. yy
|
||||||
love.graphics.print(string, viewx + 4, viewy + 4)
|
love.graphics.print(string, viewx + 4, viewy + 4)
|
||||||
print(viewy)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CameraSystem:drawHUD(id)
|
function CameraSystem:drawHUD(id)
|
||||||
|
@ -326,11 +343,11 @@ function CameraSystem:drawHUD(id)
|
||||||
local string2 = id .. " (" .. viewx .. ":" .. (viewh-viewy) .. ") "
|
local string2 = id .. " (" .. viewx .. ":" .. (viewh-viewy) .. ") "
|
||||||
|
|
||||||
|
|
||||||
love.graphics.setScissor(viewx, viewh-viewy, vieww, viewh)
|
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
||||||
love.graphics.translate(viewx, viewh-viewy)
|
love.graphics.translate(viewx, viewy)
|
||||||
view.target:drawHUD(id, vieww, viewh)
|
view.target:drawHUD(id, vieww, viewh)
|
||||||
|
|
||||||
love.graphics.translate(-viewx, -(viewh-viewy))
|
love.graphics.translate(-viewx, -(viewy))
|
||||||
love.graphics.setScissor( )
|
love.graphics.setScissor( )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue