Ingame's Player is now mandatory; player spawn on right position

This commit is contained in:
minjaesong
2017-07-18 00:19:55 +09:00
parent fe0f87e428
commit b6f92d87cc
17 changed files with 224 additions and 71 deletions

View File

@@ -2,6 +2,7 @@
package net.torvald.terrarum.gameworld
import com.badlogic.gdx.graphics.Color
import net.torvald.dataclass.Float16
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.blockproperties.BlockCodex
import org.dyn4j.geometry.Vector2
@@ -34,6 +35,7 @@ class GameWorld(val width: Int, val height: Int) {
var gravitation: Vector2 = Vector2(0.0, 9.8)
/** 0.0..1.0+ */
var globalLight = Color(0f,0f,0f,0f)
var averageTemperature = 288f // 15 deg celsius; simulates global warming
@@ -56,7 +58,7 @@ class GameWorld(val width: Int, val height: Int) {
layerTerrainLowBits = PairedMapLayer(width, height)
layerWallLowBits = PairedMapLayer(width, height)
layerThermal = MapLayerFloat(width / 2, height / 2)
layerThermal = MapLayerFloat(width / 2, height / 2, averageTemperature)
time = WorldTime(
@@ -287,6 +289,12 @@ class GameWorld(val width: Int, val height: Int) {
fun getWallDamage(x: Int, y: Int): Float =
wallDamages[LandUtil.getBlockAddr(x, y)] ?: 0f
fun getTemperature(worldTileX: Int, worldTileY: Int): Float? {
return layerThermal.getValue((worldTileX fmod width) / 2, worldTileY / 2)
}
companion object {
@Transient val WALL = 0

View File

@@ -10,6 +10,10 @@ import net.torvald.dataclass.Float16Bits
*/
class MapLayerFloat(val width: Int, val height: Int) : Iterable<Float16Bits> {
constructor(width: Int, height: Int, init: Float) : this(width, height) {
data = Array(height) { Array(width, { Float16.fromFloat(init) }) }
}
internal @Volatile var data: Array<Array<Float16Bits>> // in parallel programming: do not trust your register; always read freshly from RAM!
init {
@@ -45,7 +49,7 @@ class MapLayerFloat(val width: Int, val height: Int) : Iterable<Float16Bits> {
return if (x !in 0..width - 1 || y !in 0..height - 1)
null
else
data[y][x].toFloat()
Float16.toFloat(data[y][x])
}
internal fun setValue(x: Int, y: Int, value: Float) {

View File

@@ -155,6 +155,12 @@ object WorldSimulator {
}
}
fun disperseHeat(delta: Float) {
}
fun drawFluidMapDebug(batch: SpriteBatch) {
batch.color = colourWater