feat(screen): add a way to get coordinate and scale

This commit is contained in:
Kazhnuz 2019-07-14 15:51:58 +02:00
parent 208c523248
commit 1c8c2d6937
3 changed files with 18 additions and 0 deletions

View File

@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **examples:** Test all player number and camera types
- **core.screen:** Add a way to get coordinate and scale
### Changed
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors

View File

@ -87,6 +87,14 @@ function CScreen.project(x, y)
return math.floor((x - tx) / fsv), math.floor((y - ty) / fsv)
end
function CScreen.getScale()
return fsv
end
function CScreen.getScreenCoordinate(x, y)
return math.floor((x + tx) * fsv), math.floor((y + ty) * fsv)
end
-- Change letterbox color
function CScreen.setColor(r, g, b, a)
cr = r

View File

@ -66,6 +66,14 @@ function ScreenManager:getMousePosition()
return CScreen.project(love.mouse.getX(), love.mouse.getY())
end
function ScreenManager:getScale()
return CScreen.getScale()
end
function ScreenManager:getScreenCoordinate(x, y)
return CScreen.getScreenCoordinate(x, y)
end
-- INFO FUNCTIONS
-- Get screen informations