mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 08:36:07 +09:00
no stuttering zoom (inefficient)
This commit is contained in:
@@ -250,11 +250,17 @@ object IngameRenderer : Disposable {
|
|||||||
aTex.bind(1)
|
aTex.bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.shader = shaderBlendGlow
|
batch.shader = shaderBlendGlow
|
||||||
shaderBlendGlow.setUniformi("tex1", 1)
|
shaderBlendGlow.setUniformi("tex1", 1)
|
||||||
batch.draw(rgbTex, 0f, 0f, rgbTex.width * zoom, rgbTex.height * zoom)
|
batch.draw(rgbTex,
|
||||||
|
-0.5f * rgbTex.width * zoom + 0.5f * rgbTex.width,
|
||||||
|
-0.5f * rgbTex.height * zoom + 0.5f * rgbTex.height,
|
||||||
|
rgbTex.width * zoom,
|
||||||
|
rgbTex.height * zoom
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -268,8 +274,12 @@ object IngameRenderer : Disposable {
|
|||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.shader = null
|
batch.shader = null
|
||||||
batch.draw(rgbTex, 0f, 0f, rgbTex.width * zoom, rgbTex.height * zoom)
|
batch.draw(rgbTex,
|
||||||
|
-0.5f * rgbTex.width * zoom + 0.5f * rgbTex.width,
|
||||||
|
-0.5f * rgbTex.height * zoom + 0.5f * rgbTex.height,
|
||||||
|
rgbTex.width * zoom,
|
||||||
|
rgbTex.height * zoom
|
||||||
|
)
|
||||||
|
|
||||||
// indicator
|
// indicator
|
||||||
batch.color = Color.RED
|
batch.color = Color.RED
|
||||||
@@ -291,8 +301,12 @@ object IngameRenderer : Disposable {
|
|||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.shader = null
|
batch.shader = null
|
||||||
batch.draw(aTex, 0f, 0f, aTex.width * zoom, aTex.height * zoom)
|
batch.draw(aTex,
|
||||||
|
-0.5f * aTex.width * zoom + 0.5f * aTex.width,
|
||||||
|
-0.5f * aTex.height * zoom + 0.5f * aTex.height,
|
||||||
|
aTex.width * zoom,
|
||||||
|
aTex.height * zoom
|
||||||
|
)
|
||||||
|
|
||||||
// indicator
|
// indicator
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class UIScreenZoom : UICanvas(
|
|||||||
override var width = AppLoader.fontGame.getWidth(zoomText)
|
override var width = AppLoader.fontGame.getWidth(zoomText)
|
||||||
override var height = AppLoader.fontGame.lineHeight.toInt()
|
override var height = AppLoader.fontGame.lineHeight.toInt()
|
||||||
|
|
||||||
override var openCloseTime = 0.3f
|
override var openCloseTime = 0.2f
|
||||||
|
|
||||||
override val mouseUp = false
|
override val mouseUp = false
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.torvald.terrarum.worlddrawer
|
|||||||
|
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.floorInt
|
import net.torvald.terrarum.floorInt
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
@@ -15,8 +14,8 @@ import org.dyn4j.geometry.Vector2
|
|||||||
object WorldCamera {
|
object WorldCamera {
|
||||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||||
|
|
||||||
val zoom: Float
|
//val zoom: Float
|
||||||
get() = Terrarum.ingame?.screenZoom ?: 1f
|
// get() = Terrarum.ingame?.screenZoom ?: 1f
|
||||||
|
|
||||||
var x: Int = 0 // left position
|
var x: Int = 0 // left position
|
||||||
private set
|
private set
|
||||||
@@ -27,9 +26,9 @@ object WorldCamera {
|
|||||||
var yEnd: Int = 0 // bottom position
|
var yEnd: Int = 0 // bottom position
|
||||||
private set
|
private set
|
||||||
inline val gdxCamX: Float // centre position
|
inline val gdxCamX: Float // centre position
|
||||||
get() = (x + width / 2f * zoom).toInt().toFloat()
|
get() = xCentre.toFloat()
|
||||||
inline val gdxCamY: Float// centre position
|
inline val gdxCamY: Float// centre position
|
||||||
get() = (y + height / 2f * zoom).toInt().toFloat()
|
get() = yCentre.toFloat()
|
||||||
var width: Int = 0
|
var width: Int = 0
|
||||||
private set
|
private set
|
||||||
var height: Int = 0
|
var height: Int = 0
|
||||||
@@ -44,8 +43,8 @@ object WorldCamera {
|
|||||||
fun update(world: GameWorld, player: ActorWithBody?) {
|
fun update(world: GameWorld, player: ActorWithBody?) {
|
||||||
if (player == null) return
|
if (player == null) return
|
||||||
|
|
||||||
width = FastMath.ceil(AppLoader.screenW / zoom) // div, not mul
|
width = AppLoader.screenW//FastMath.ceil(AppLoader.screenW / zoom) // div, not mul
|
||||||
height = FastMath.ceil(AppLoader.screenH / zoom)
|
height = AppLoader.screenH//FastMath.ceil(AppLoader.screenH / zoom)
|
||||||
|
|
||||||
// TOP-LEFT position of camera border
|
// TOP-LEFT position of camera border
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user