screen zooming, temporarily toggle with Z key

This commit is contained in:
minjaesong
2019-08-11 05:42:04 +09:00
parent 08c18caa25
commit 419773550a
11 changed files with 61 additions and 17 deletions

View File

@@ -635,7 +635,8 @@ internal object BlocksDrawer {
else
0f
)
shader.setUniformf("drawBreakage", if (mode == WIRE) 0f else 1f)
//shader.setUniformf("drawBreakage", if (mode == WIRE) 0f else 1f)
shader.setUniformf("zoom", Terrarum.ingame?.screenZoom ?: 1f)
tilesQuad.render(shader, GL20.GL_TRIANGLES)
shader.end()

View File

@@ -15,6 +15,9 @@ import org.dyn4j.geometry.Vector2
object WorldCamera {
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
val zoom: Float
get() = Terrarum.ingame?.screenZoom ?: 1f
var x: Int = 0 // left position
private set
var y: Int = 0 // top position
@@ -24,9 +27,9 @@ object WorldCamera {
var yEnd: Int = 0 // bottom position
private set
inline val gdxCamX: Float // centre position
get() = xCentre.toFloat()
get() = (x + width / 2f * zoom).toInt().toFloat()
inline val gdxCamY: Float// centre position
get() = yCentre.toFloat()
get() = (y + height / 2f * zoom).toInt().toFloat()
var width: Int = 0
private set
var height: Int = 0
@@ -41,8 +44,8 @@ object WorldCamera {
fun update(world: GameWorld, player: ActorWithBody?) {
if (player == null) return
width = FastMath.ceil(AppLoader.screenW / (Terrarum.ingame?.screenZoom ?: 1f)) // div, not mul
height = FastMath.ceil(AppLoader.screenH / (Terrarum.ingame?.screenZoom ?: 1f))
width = FastMath.ceil(AppLoader.screenW / zoom) // div, not mul
height = FastMath.ceil(AppLoader.screenH / zoom)
// TOP-LEFT position of camera border