terrain texture change by all seasons

This commit is contained in:
minjaesong
2019-02-01 15:59:54 +09:00
parent 29fbad889b
commit e2dec79ca5
7 changed files with 43 additions and 20 deletions

Binary file not shown.

View File

@@ -23,6 +23,7 @@ import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.IngameRenderer import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.gameactors.HumanoidNPC import net.torvald.terrarum.modulebasegame.gameactors.HumanoidNPC
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
@@ -129,7 +130,8 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
demoWorld = ReadLayerData(FileInputStream(ModMgr.getFile("basegame", "demoworld"))) demoWorld = ReadLayerData(FileInputStream(ModMgr.getFile("basegame", "demoworld")))
// set time to summer
demoWorld.time.addTime(WorldTime.DAY_LENGTH * 32)
// construct camera nodes // construct camera nodes
val nodeCount = 100 val nodeCount = 100

View File

@@ -70,6 +70,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
} }
} }
// set time to summer
gameWorld.time.addTime(WorldTime.DAY_LENGTH * 32)
world = gameWorld world = gameWorld
} }

View File

@@ -42,10 +42,12 @@ internal object BlocksDrawer {
* If not, the engine will choose wrong tile for a number you provided. * If not, the engine will choose wrong tile for a number you provided.
*/ */
val tilesTerrain: TextureRegionPack /** Index zero: spring */
val weatherTerrains: Array<TextureRegionPack>
lateinit var tilesTerrain: TextureRegionPack; private set
lateinit var tilesTerrainBlend: TextureRegionPack; private set
val tilesWire: TextureRegionPack val tilesWire: TextureRegionPack
val tileItemWall: TextureRegionPack val tileItemWall: TextureRegionPack
val tilesTerrainBlend: TextureRegionPack
val tilesFluid: TextureRegionPack val tilesFluid: TextureRegionPack
//val tileItemWall = Image(TILE_SIZE * 16, TILE_SIZE * GameWorld.TILES_SUPPORTED / 16) // 4 MB //val tileItemWall = Image(TILE_SIZE * 16, TILE_SIZE * GameWorld.TILES_SUPPORTED / 16) // 4 MB
@@ -97,8 +99,8 @@ internal object BlocksDrawer {
// -- Torvald, 2018-12-19 // -- Torvald, 2018-12-19
// hard-coded as tga.gz // hard-coded as tga.gz
val gzFileList = listOf("blocks/terrain.tga.gz", "blocks/wire.tga.gz", "blocks/terrain_autumn.tga.gz", "blocks/fluids.tga.gz") val gzFileList = listOf("blocks/wire.tga.gz", "blocks/fluids.tga.gz", "blocks/terrain_spring.tga.gz", "blocks/terrain.tga.gz", "blocks/terrain_autumn.tga.gz", "blocks/terrain_winter.tga.gz")
val gzTmpFName = listOf("tmp_terrain.tga", "tmp_wire.tga", "tmp_terrain_autumn.tga", "tmp_fluids.tga") val gzTmpFName = listOf("tmp_wire.tga", "tmp_fluids.tga", "tmp_vor.tga", "tmp_sumar.tga", "tmp_haust.tga", "tmp_vetter.tga")
// unzip GZIP temporarily // unzip GZIP temporarily
gzFileList.forEachIndexed { index, filename -> gzFileList.forEachIndexed { index, filename ->
val terrainTexFile = ModMgr.getGdxFile("basegame", filename) val terrainTexFile = ModMgr.getGdxFile("basegame", filename)
@@ -111,27 +113,29 @@ internal object BlocksDrawer {
fos.close() fos.close()
} }
val _terrainPixMap = Pixmap(Gdx.files.internal(gzTmpFName[0])) val _wirePixMap = Pixmap(Gdx.files.internal(gzTmpFName[0]))
val _wirePixMap = Pixmap(Gdx.files.internal(gzTmpFName[1])) val _fluidPixMap = Pixmap(Gdx.files.internal(gzTmpFName[1]))
val _terrainBlendPixMap = Pixmap(Gdx.files.internal(gzTmpFName[2]))
val _fluidPixMap = Pixmap(Gdx.files.internal(gzTmpFName[3])) val _terrainPixMap = Array(4) { Pixmap(Gdx.files.internal(gzTmpFName[it + 2])) }
// delete temp files // delete temp files
gzTmpFName.forEach { File(it).delete() } gzTmpFName.forEach { File(it).delete() }
tilesTerrain = TextureRegionPack(Texture(_terrainPixMap), TILE_SIZE, TILE_SIZE)
tilesTerrain.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) weatherTerrains = Array(4) {
val t = TextureRegionPack(Texture(_terrainPixMap[it]), TILE_SIZE, TILE_SIZE)
t.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
t
}
tilesWire = TextureRegionPack(Texture(_wirePixMap), TILE_SIZE, TILE_SIZE) tilesWire = TextureRegionPack(Texture(_wirePixMap), TILE_SIZE, TILE_SIZE)
tilesWire.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) tilesWire.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
tilesTerrainBlend = TextureRegionPack(Texture(_terrainBlendPixMap), TILE_SIZE, TILE_SIZE)
tilesTerrainBlend.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
tilesFluid = TextureRegionPack(Texture(_fluidPixMap), TILE_SIZE, TILE_SIZE) tilesFluid = TextureRegionPack(Texture(_fluidPixMap), TILE_SIZE, TILE_SIZE)
tilesFluid.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) tilesFluid.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
// also dispose unused temp files // also dispose unused temp files
//terrainPixMap.dispose() // commented: tileItemWall needs it //terrainPixMap.dispose() // commented: tileItemWall needs it
_wirePixMap.dispose() _wirePixMap.dispose()
_terrainBlendPixMap.dispose()
_fluidPixMap.dispose() _fluidPixMap.dispose()
@@ -140,10 +144,13 @@ internal object BlocksDrawer {
// create item_wall images // create item_wall images
// will just use the terrain texture :p // will just use the terrain texture :p
tileItemWall = tilesTerrain tileItemWall = weatherTerrains[1]
_terrainPixMap.dispose() // finally _terrainPixMap.forEach { it.dispose() } // finally
tilesTerrain = weatherTerrains[1]
printdbg(this, "init() exit") printdbg(this, "init() exit")
@@ -340,6 +347,12 @@ internal object BlocksDrawer {
/////////////////////////////////////////// ///////////////////////////////////////////
internal fun renderData() { internal fun renderData() {
try {
tilesTerrain = weatherTerrains[(world as GameWorldExtension).time.months - 1]
tilesTerrainBlend = weatherTerrains[(world as GameWorldExtension).time.months fmod 4]
}
catch (e: ClassCastException) { }
drawTiles(WALL) drawTiles(WALL)
drawTiles(TERRAIN) // regular tiles drawTiles(TERRAIN) // regular tiles
drawTiles(WIRE) drawTiles(WIRE)
@@ -735,7 +748,7 @@ internal object BlocksDrawer {
/*shader hard-code*/shader.setUniformi("tilesInAtlas", tileAtlas.horizontalCount, tileAtlas.verticalCount) //depends on the tile atlas /*shader hard-code*/shader.setUniformi("tilesInAtlas", tileAtlas.horizontalCount, tileAtlas.verticalCount) //depends on the tile atlas
/*shader hard-code*/shader.setUniformi("atlasTexSize", tileAtlas.texture.width, tileAtlas.texture.height) //depends on the tile atlas /*shader hard-code*/shader.setUniformi("atlasTexSize", tileAtlas.texture.width, tileAtlas.texture.height) //depends on the tile atlas
// set the blend value as world's time progresses, in linear fashion // set the blend value as world's time progresses, in linear fashion
shader.setUniformf("tilesBlend", if (world is GameWorldExtension && mode != FLUID) shader.setUniformf("tilesBlend", if (world is GameWorldExtension && (mode == TERRAIN || mode == WALL))
(world as GameWorldExtension).time.days.minus(1f) / WorldTime.MONTH_LENGTH (world as GameWorldExtension).time.days.minus(1f) / WorldTime.MONTH_LENGTH
else else
0f 0f

Binary file not shown.

Binary file not shown.

Binary file not shown.