mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
backend stuffs in the Terrarum moved to the AppLoader
This commit is contained in:
@@ -3,12 +3,9 @@ package net.torvald.terrarum.worlddrawer
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.ColourTemp
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendMul
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockstats.BlockStats
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
|
||||
@@ -46,7 +43,7 @@ object FeaturesDrawer {
|
||||
* usually targeted for the environmental temperature (desert/winterland), hence the name.
|
||||
*/
|
||||
fun drawEnvOverlay(batch: SpriteBatch) {
|
||||
val onscreen_tiles_max = FastMath.ceil(Terrarum.HEIGHT * Terrarum.WIDTH / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_max = FastMath.ceil(AppLoader.screenH * AppLoader.screenW / 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()
|
||||
@@ -60,8 +57,8 @@ object FeaturesDrawer {
|
||||
|
||||
batch.color = ColourTemp(colTemp)
|
||||
batch.fillRect(0f, 0f,
|
||||
Terrarum.WIDTH * if (zoom < 1) 1f / zoom else zoom,
|
||||
Terrarum.HEIGHT * if (zoom < 1) 1f / zoom else zoom
|
||||
AppLoader.screenW * if (zoom < 1) 1f / zoom else zoom,
|
||||
AppLoader.screenH * if (zoom < 1) 1f / zoom else zoom
|
||||
)
|
||||
|
||||
blendNormal(batch)
|
||||
|
||||
@@ -80,8 +80,8 @@ object LightmapRenderer {
|
||||
|
||||
// TODO resize(int, int) -aware
|
||||
|
||||
var LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.WIDTH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
var LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.HEIGHT).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
var LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(AppLoader.screenW).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
var LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(AppLoader.screenH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
private val noopMask = HashSet<Point2i>((LIGHTMAP_WIDTH + LIGHTMAP_HEIGHT) * 2)
|
||||
|
||||
@@ -754,8 +754,8 @@ object LightmapRenderer {
|
||||
val tilesInHorizontal = (screenW.toFloat() / TILE_SIZE).ceilInt() + 1
|
||||
val tilesInVertical = (screenH.toFloat() / TILE_SIZE).ceilInt() + 1
|
||||
|
||||
LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.WIDTH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.HEIGHT).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(AppLoader.screenW).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(AppLoader.screenH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
if (_init) {
|
||||
lightBuffer.dispose()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
@@ -39,8 +40,8 @@ object WorldCamera {
|
||||
fun update(world: GameWorld, player: ActorWithBody?) {
|
||||
if (player == null) return
|
||||
|
||||
width = FastMath.ceil(Terrarum.WIDTH / (Terrarum.ingame?.screenZoom ?: 1f)) // div, not mul
|
||||
height = FastMath.ceil(Terrarum.HEIGHT / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||
width = FastMath.ceil(AppLoader.screenW / (Terrarum.ingame?.screenZoom ?: 1f)) // div, not mul
|
||||
height = FastMath.ceil(AppLoader.screenH / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||
|
||||
// TOP-LEFT position of camera border
|
||||
|
||||
@@ -64,8 +65,8 @@ object WorldCamera {
|
||||
private fun Int.clampCameraY(world: GameWorld): Int {
|
||||
return if (this < 0)
|
||||
0
|
||||
else if (this > world.height.times(TILE_SIZE) - Terrarum.HEIGHT)
|
||||
world.height.times(TILE_SIZE) - Terrarum.HEIGHT
|
||||
else if (this > world.height.times(TILE_SIZE) - AppLoader.screenH)
|
||||
world.height.times(TILE_SIZE) - AppLoader.screenH
|
||||
else
|
||||
this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user