mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
downsampling sorta works, ONLY WHEN (width or height % 4) is 0 or 1
This commit is contained in:
@@ -47,7 +47,7 @@ object FeaturesDrawer {
|
||||
* usually targeted for the environmental temperature (desert/winterland), hence the name.
|
||||
*/
|
||||
fun drawEnvOverlay(batch: SpriteBatch) {
|
||||
val onscreen_tiles_max = FastMath.ceil(Gdx.graphics.height * Gdx.graphics.width / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_max = FastMath.ceil(TerrarumGDX.HEIGHT * TerrarumGDX.WIDTH / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_cap = onscreen_tiles_max / 4f
|
||||
val onscreen_cold_tiles = BlockStats.getCount(*TILES_COLD).toFloat()
|
||||
val onscreen_warm_tiles = BlockStats.getCount(*TILES_WARM).toFloat()
|
||||
@@ -62,8 +62,8 @@ object FeaturesDrawer {
|
||||
batch.color = ColourTemp(colTemp)
|
||||
batch.fillRect(WorldCamera.x * zoom,
|
||||
WorldCamera.y * zoom,
|
||||
Gdx.graphics.width * if (zoom < 1) 1f / zoom else zoom,
|
||||
Gdx.graphics.height * if (zoom < 1) 1f / zoom else zoom
|
||||
TerrarumGDX.WIDTH * if (zoom < 1) 1f / zoom else zoom,
|
||||
TerrarumGDX.HEIGHT * if (zoom < 1) 1f / zoom else zoom
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ object LightmapRenderer {
|
||||
|
||||
// TODO resize(int, int) -aware
|
||||
|
||||
val LIGHTMAP_WIDTH = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(Gdx.graphics.width)
|
||||
val LIGHTMAP_WIDTH = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.WIDTH)
|
||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
val LIGHTMAP_HEIGHT = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(Gdx.graphics.height)
|
||||
val LIGHTMAP_HEIGHT = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.HEIGHT)
|
||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
/**
|
||||
@@ -351,7 +351,7 @@ object LightmapRenderer {
|
||||
(x * DRAW_TILE_SIZE).round().toFloat(),
|
||||
(y * DRAW_TILE_SIZE).round().toFloat(),
|
||||
(DRAW_TILE_SIZE.ceil() * sameLevelCounter).toFloat(),
|
||||
DRAW_TILE_SIZE.ceil().toFloat()
|
||||
DRAW_TILE_SIZE.ceil().toFloat() + 1f
|
||||
)
|
||||
|
||||
x += sameLevelCounter - 1
|
||||
|
||||
@@ -3,7 +3,12 @@ package net.torvald.terrarum.worlddrawer
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.ceilInt
|
||||
import net.torvald.terrarum.gameactors.floor
|
||||
import net.torvald.terrarum.gameactors.floorInt
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.round
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-12-30.
|
||||
@@ -34,26 +39,21 @@ object WorldCamera {
|
||||
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
|
||||
width = FastMath.ceil(Gdx.graphics.width / TerrarumGDX.ingame!!.screenZoom) // div, not mul
|
||||
height = FastMath.ceil(Gdx.graphics.height / TerrarumGDX.ingame!!.screenZoom)
|
||||
width = FastMath.ceil(TerrarumGDX.WIDTH / TerrarumGDX.ingame!!.screenZoom) // div, not mul
|
||||
height = FastMath.ceil(TerrarumGDX.HEIGHT / TerrarumGDX.ingame!!.screenZoom)
|
||||
|
||||
// position - (WH / 2)
|
||||
x = Math.round(// X only: ROUNDWORLD implementation
|
||||
(player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2)
|
||||
y = Math.round(FastMath.clamp(
|
||||
x = (// X only: ROUNDWORLD implementation
|
||||
(player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2).roundInt()
|
||||
y = (FastMath.clamp(
|
||||
(player?.hitbox?.centeredY?.toFloat() ?: 0f) - height / 2,
|
||||
TILE_SIZE.toFloat(),
|
||||
world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat()
|
||||
))
|
||||
)).roundInt()
|
||||
|
||||
|
||||
gdxCamX = Math.round(// X only: ROUNDWORLD implementation
|
||||
(player?.hitbox?.centeredX?.toFloat() ?: 0f)).toFloat()
|
||||
gdxCamY = Math.round(FastMath.clamp(
|
||||
(player?.hitbox?.centeredY?.toFloat() ?: 0f),
|
||||
TILE_SIZE.toFloat(),
|
||||
world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat()
|
||||
)).toFloat()
|
||||
gdxCamX = x + (width / 2f).round()
|
||||
gdxCamY = y + (height / 2f).round()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user