From 6b37b2b9d69fb66e9cd50a68f807ec2f3b6112e3 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 3 Jul 2017 19:26:00 +0900 Subject: [PATCH] putting ore vein prototype on main sheet; also a commit before fuck-up --- .../terrarum-sans-bitmap/cyrilic_variable.tga | 2 +- assets/modules/basegame/blocks/terrain.tga.gz | 4 +-- src/net/torvald/terrarum/StateInGameGDX.kt | 24 ++++++++++------ src/net/torvald/terrarum/TerrarumGDX.kt | 7 +++-- src/net/torvald/terrarum/ui/UIHandler.kt | 7 +++++ .../torvald/terrarum/weather/WeatherMixer.kt | 5 ++-- .../terrarum/worlddrawer/BlocksDrawer_old.kt | 28 +++++++++++++++---- .../graphics/fonts/cyrilic_variable.psd | 4 +-- work_files/graphics/terrain/terrain.psd.gz | 4 +-- 9 files changed, 57 insertions(+), 28 deletions(-) diff --git a/assets/graphics/fonts/terrarum-sans-bitmap/cyrilic_variable.tga b/assets/graphics/fonts/terrarum-sans-bitmap/cyrilic_variable.tga index 9ed5e7d97..bef5d99b7 100644 --- a/assets/graphics/fonts/terrarum-sans-bitmap/cyrilic_variable.tga +++ b/assets/graphics/fonts/terrarum-sans-bitmap/cyrilic_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8c05c12eef217e32a4d2a55ed060736e0e8d6b7b603c4be04ef5b5a41c726aa +oid sha256:b99a942250f176fe695215ea9a452034e4eba778d76beb3b75e3c9a97e73e407 size 389164 diff --git a/assets/modules/basegame/blocks/terrain.tga.gz b/assets/modules/basegame/blocks/terrain.tga.gz index fb85a45e2..3f0e71f43 100644 --- a/assets/modules/basegame/blocks/terrain.tga.gz +++ b/assets/modules/basegame/blocks/terrain.tga.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4848204132e9bd906f0ef6c3bd829853dc2d25c49c570ee03b8d7e6cc36037b -size 3015858 +oid sha256:39d99625d569412bdd0dc48f6bc06d704393cfc44cea59c5fc10ee249d4cf6de +size 3017254 diff --git a/src/net/torvald/terrarum/StateInGameGDX.kt b/src/net/torvald/terrarum/StateInGameGDX.kt index 3fc6e7999..fd93decd4 100644 --- a/src/net/torvald/terrarum/StateInGameGDX.kt +++ b/src/net/torvald/terrarum/StateInGameGDX.kt @@ -393,8 +393,6 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { batch.color = Color.WHITE blendNormal() - - BlocksDrawer.renderWall(batch) actorsRenderBehind.forEach { it.drawBody(batch) } actorsRenderBehind.forEach { it.drawGlow(batch) } @@ -425,7 +423,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { blendNormal() else blendMul() - //LightmapRenderer.draw(batch) + LightmapRenderer.draw(batch) ////////////////////// @@ -447,9 +445,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { // draw to main screen // ///////////////////////// batch.inUse { - camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work - camera.update() - batch.projectionMatrix = camera.combined + setCameraPosition(0f, 0f) batch.color = Color.WHITE blendNormal() @@ -527,9 +523,8 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { ///////////////////////////// // draw some overlays (UI) // ///////////////////////////// - uiContainer.forEach { if (it != consoleHandler) it.render(batch) } // FIXME draws black of grey coloured box on top right - batch.color = Color.WHITE + debugWindow.render(batch) // make sure console draws on top of other UIs consoleHandler.render(batch) @@ -556,7 +551,6 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { // draw map related stuffs // ///////////////////////////// /*worldDrawFrameBuffer.inAction { - // FIXME wrong and flipped coord; one camera code does not concern other batch.inUse { camera.position.set(WorldCamera.x.toFloat(), WorldCamera.y.toFloat(), 0f) // make camara work @@ -1096,4 +1090,16 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { override fun dispose() { worldDrawFrameBuffer.dispose() } + + + /** + * WARNING! this function flushes batch; use this sparingly! + * + * Camera will be moved so that (newX, newY) would be sit on the top-left edge. + */ + fun setCameraPosition(newX: Float, newY: Float) { + camera.position.set(newX + TerrarumGDX.HALFW, newY + TerrarumGDX.HALFH, 0f) + camera.update() + batch.projectionMatrix = camera.combined + } } diff --git a/src/net/torvald/terrarum/TerrarumGDX.kt b/src/net/torvald/terrarum/TerrarumGDX.kt index efd43d903..aa6d59c1d 100644 --- a/src/net/torvald/terrarum/TerrarumGDX.kt +++ b/src/net/torvald/terrarum/TerrarumGDX.kt @@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.GL30 import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.BitmapFont +import com.badlogic.gdx.graphics.g2d.CpuSpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.ShapeRenderer @@ -41,7 +42,7 @@ fun main(args: Array) { config.foregroundFPS = TerrarumGDX.RENDER_FPS config.backgroundFPS = TerrarumGDX.RENDER_FPS //config.vSyncEnabled = true - config.resizable = false + config.resizable = true config.width = 1072 config.height = 742 config.backgroundFPS = 9999 @@ -514,8 +515,8 @@ inline fun FrameBuffer.inAction(action: (FrameBuffer) -> Unit) { // ShapeRenderer alternative for rects -inline fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) { - this.draw(net.torvald.terrarum.TerrarumGDX.orthoLineTex2px, x, y, w, h) +fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) { + this.draw(net.torvald.terrarum.worlddrawer.BlocksDrawer.tilesTerrain.get(1, 0), x, y, w, h) } inline fun SpriteBatch.drawStraightLine(x: Float, y: Float, p2: Float, thickness: Float, isVertical: Boolean) { if (!isVertical) diff --git a/src/net/torvald/terrarum/ui/UIHandler.kt b/src/net/torvald/terrarum/ui/UIHandler.kt index 32406357c..1a3182f6c 100644 --- a/src/net/torvald/terrarum/ui/UIHandler.kt +++ b/src/net/torvald/terrarum/ui/UIHandler.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.ui +import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.math.Matrix4 import net.torvald.terrarum.TerrarumGDX @@ -135,6 +136,12 @@ class UIHandler(val UI: UICanvas, //if (!customPositioning) // TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work? + + + if (!customPositioning) + TerrarumGDX.ingame?.setCameraPosition(posX.toFloat(), posY.toFloat()) + batch.color = Color.WHITE + UI.render(batch) //ingameGraphics.flush() } diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 1cc677ad8..0679e7b9e 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -118,12 +118,11 @@ object WeatherMixer { // draw skybox to provided graphics instance batch.end() - blendNormal() TerrarumGDX.inShapeRenderer { it.rect( 0f, 0f, - Gdx.graphics.width.toFloat(),// / TerrarumGDX.ingame!!.screenZoom, - Gdx.graphics.height.toFloat(),// / TerrarumGDX.ingame!!.screenZoom + Gdx.graphics.width.toFloat(), + Gdx.graphics.height.toFloat(), getGradientColour(skyboxColourMap, 1, timeNow), getGradientColour(skyboxColourMap, 1, timeNow), getGradientColour(skyboxColourMap, 0, timeNow), diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt index 3cf98728e..a68640846 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt @@ -381,6 +381,25 @@ object BlocksDrawer { private val tileDrawLightThreshold = 2 + private fun canIHazRender(mode: Int, x: Int, y: Int) = + (world.getTileFrom(mode, x, y) != 0) && // not an air tile + // for WALLs: + if (mode == WALL) + mode == WALL && ( + // DRAW WHEN it is visible and 'is a lip' + !BlockCodex[world.getTileFromTerrain(x, y) ?: 0].isSolid || + !(BlockCodex[world.getTileFromTerrain(x, y) ?: 0].isSolid && + ((BlockCodex[world.getTileFromTerrain(x, y - 1) ?: 0].isSolid && BlockCodex[world.getTileFromTerrain(x, y + 1) ?: 0].isSolid) + && + (BlockCodex[world.getTileFromTerrain(x - 1, y) ?: 0].isSolid && BlockCodex[world.getTileFromTerrain(x + 1, y + 1) ?: 0].isSolid) + ) + ) + ) + else + true + + // end + private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean, color: Color) { val for_y_start = y / TILE_SIZE val for_y_end = BlocksDrawer.clampHTile(for_y_start + (height / TILE_SIZE) + 2) @@ -411,8 +430,7 @@ object BlocksDrawer { // draw a tile, but only when illuminated try { - if ((mode == WALL || mode == TERRAIN) && // not an air tile - (thisTile ?: 0) != Block.AIR) { + if (canIHazRender(mode, x, y)) { // check if light level of nearby or this tile is illuminated if ( LightmapRenderer.getHighestRGB(x, y) ?: 0 >= tileDrawLightThreshold || LightmapRenderer.getHighestRGB(x - 1, y) ?: 0 >= tileDrawLightThreshold || @@ -489,10 +507,8 @@ object BlocksDrawer { else { zeroTileCounter++ // unused for now - //batch.color = Color.BLACK - - batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF) - + batch.color = Color.BLACK + drawTile(batch, mode, x, y, 1, 0) batch.color = color } } // end if (not an air) diff --git a/work_files/graphics/fonts/cyrilic_variable.psd b/work_files/graphics/fonts/cyrilic_variable.psd index 6920d5906..792e23523 100644 --- a/work_files/graphics/fonts/cyrilic_variable.psd +++ b/work_files/graphics/fonts/cyrilic_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f21d975638100233d52d276a10addd3e3d8f500322da74cde656ef9328f6599 -size 396896 +oid sha256:6ece2bf3180fd66b46f00851f69816b9adc293c732b3a7edb36b4592cecab383 +size 396872 diff --git a/work_files/graphics/terrain/terrain.psd.gz b/work_files/graphics/terrain/terrain.psd.gz index 026f645d0..721c10dd4 100644 --- a/work_files/graphics/terrain/terrain.psd.gz +++ b/work_files/graphics/terrain/terrain.psd.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c70f1c529b71e9d02c616e4e0fd3525bfa7e669f1b896d8f79d3ddc460521079 -size 522778 +oid sha256:a7e238df32ed73d4cda6eb102264295d313e29367a38532d10eaea9f0cd1a601 +size 528865