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 5c24f57d03
commit 8774506690
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
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
}
}

View File

@@ -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<String>) {
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)

View File

@@ -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()
}

View File

@@ -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),

View File

@@ -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)

Binary file not shown.