putting ore vein prototype on main sheet; also a commit before fuck-up

This commit is contained in:
minjaesong
2017-07-03 19:26:00 +09:00
parent 2ea3ce0c67
commit b7fb8ff4da
9 changed files with 57 additions and 28 deletions

View File

@@ -393,8 +393,6 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
batch.color = Color.WHITE batch.color = Color.WHITE
blendNormal() blendNormal()
BlocksDrawer.renderWall(batch) BlocksDrawer.renderWall(batch)
actorsRenderBehind.forEach { it.drawBody(batch) } actorsRenderBehind.forEach { it.drawBody(batch) }
actorsRenderBehind.forEach { it.drawGlow(batch) } actorsRenderBehind.forEach { it.drawGlow(batch) }
@@ -425,7 +423,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
blendNormal() blendNormal()
else else
blendMul() blendMul()
//LightmapRenderer.draw(batch) LightmapRenderer.draw(batch)
////////////////////// //////////////////////
@@ -447,9 +445,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
// draw to main screen // // draw to main screen //
///////////////////////// /////////////////////////
batch.inUse { batch.inUse {
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work setCameraPosition(0f, 0f)
camera.update()
batch.projectionMatrix = camera.combined
batch.color = Color.WHITE batch.color = Color.WHITE
blendNormal() blendNormal()
@@ -527,9 +523,8 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
///////////////////////////// /////////////////////////////
// draw some overlays (UI) // // draw some overlays (UI) //
///////////////////////////// /////////////////////////////
uiContainer.forEach { if (it != consoleHandler) it.render(batch) } // FIXME draws black of grey coloured box on top right 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) debugWindow.render(batch)
// make sure console draws on top of other UIs // make sure console draws on top of other UIs
consoleHandler.render(batch) consoleHandler.render(batch)
@@ -556,7 +551,6 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
// draw map related stuffs // // draw map related stuffs //
///////////////////////////// /////////////////////////////
/*worldDrawFrameBuffer.inAction { /*worldDrawFrameBuffer.inAction {
// FIXME wrong and flipped coord; one camera code does not concern other
batch.inUse { batch.inUse {
camera.position.set(WorldCamera.x.toFloat(), WorldCamera.y.toFloat(), 0f) // make camara work 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() { override fun dispose() {
worldDrawFrameBuffer.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
}
} }

View File

@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.GL30
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont 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.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer
@@ -41,7 +42,7 @@ fun main(args: Array<String>) {
config.foregroundFPS = TerrarumGDX.RENDER_FPS config.foregroundFPS = TerrarumGDX.RENDER_FPS
config.backgroundFPS = TerrarumGDX.RENDER_FPS config.backgroundFPS = TerrarumGDX.RENDER_FPS
//config.vSyncEnabled = true //config.vSyncEnabled = true
config.resizable = false config.resizable = true
config.width = 1072 config.width = 1072
config.height = 742 config.height = 742
config.backgroundFPS = 9999 config.backgroundFPS = 9999
@@ -514,8 +515,8 @@ inline fun FrameBuffer.inAction(action: (FrameBuffer) -> Unit) {
// ShapeRenderer alternative for rects // ShapeRenderer alternative for rects
inline fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) { fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) {
this.draw(net.torvald.terrarum.TerrarumGDX.orthoLineTex2px, x, y, w, h) 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) { inline fun SpriteBatch.drawStraightLine(x: Float, y: Float, p2: Float, thickness: Float, isVertical: Boolean) {
if (!isVertical) if (!isVertical)

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.math.Matrix4 import com.badlogic.gdx.math.Matrix4
import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.TerrarumGDX
@@ -135,6 +136,12 @@ class UIHandler(val UI: UICanvas,
//if (!customPositioning) //if (!customPositioning)
// TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work? // 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) UI.render(batch)
//ingameGraphics.flush() //ingameGraphics.flush()
} }

View File

@@ -118,12 +118,11 @@ object WeatherMixer {
// draw skybox to provided graphics instance // draw skybox to provided graphics instance
batch.end() batch.end()
blendNormal()
TerrarumGDX.inShapeRenderer { TerrarumGDX.inShapeRenderer {
it.rect( it.rect(
0f, 0f, 0f, 0f,
Gdx.graphics.width.toFloat(),// / TerrarumGDX.ingame!!.screenZoom, Gdx.graphics.width.toFloat(),
Gdx.graphics.height.toFloat(),// / TerrarumGDX.ingame!!.screenZoom Gdx.graphics.height.toFloat(),
getGradientColour(skyboxColourMap, 1, timeNow), getGradientColour(skyboxColourMap, 1, timeNow),
getGradientColour(skyboxColourMap, 1, timeNow), getGradientColour(skyboxColourMap, 1, timeNow),
getGradientColour(skyboxColourMap, 0, timeNow), getGradientColour(skyboxColourMap, 0, timeNow),

View File

@@ -381,6 +381,25 @@ object BlocksDrawer {
private val tileDrawLightThreshold = 2 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) { private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean, color: Color) {
val for_y_start = y / TILE_SIZE val for_y_start = y / TILE_SIZE
val for_y_end = BlocksDrawer.clampHTile(for_y_start + (height / TILE_SIZE) + 2) 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 // draw a tile, but only when illuminated
try { try {
if ((mode == WALL || mode == TERRAIN) && // not an air tile if (canIHazRender(mode, x, y)) {
(thisTile ?: 0) != Block.AIR) {
// check if light level of nearby or this tile is illuminated // check if light level of nearby or this tile is illuminated
if ( LightmapRenderer.getHighestRGB(x, y) ?: 0 >= tileDrawLightThreshold || if ( LightmapRenderer.getHighestRGB(x, y) ?: 0 >= tileDrawLightThreshold ||
LightmapRenderer.getHighestRGB(x - 1, y) ?: 0 >= tileDrawLightThreshold || LightmapRenderer.getHighestRGB(x - 1, y) ?: 0 >= tileDrawLightThreshold ||
@@ -489,10 +507,8 @@ object BlocksDrawer {
else { else {
zeroTileCounter++ // unused for now zeroTileCounter++ // unused for now
//batch.color = Color.BLACK batch.color = Color.BLACK
drawTile(batch, mode, x, y, 1, 0)
batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF)
batch.color = color batch.color = color
} }
} // end if (not an air) } // end if (not an air)

Binary file not shown.