removed unnecessary class Light10B, minor fixes for LightmapRenderer

Former-commit-id: 4cddfb080cc689738d9bf308f7d08852f4c78a8b
Former-commit-id: 2354b2483f30e70862a327c1b9688a19bd1b2f66
This commit is contained in:
Song Minjae
2016-09-07 22:58:42 +09:00
parent d817c586e9
commit 9b9b65efba
31 changed files with 3718 additions and 134 deletions

View File

@@ -1,5 +1,5 @@
echo "Hello, world! This is a batch test." echo "Hello, world! This is a batch test."
echo "Will add actorvalue 'batch = true' to player" echo "Will add actorvalue 'batch = __true' to player"
setav batch true setav batch true
echo "Checking if command did something." echo "Checking if command did something."
getav batch getav batch

3073
assets/getlightdata Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,8 @@ import net.torvald.colourutil.CIELabUtil.toXYZ
import org.newdawn.slick.Color import org.newdawn.slick.Color
/** /**
* RGB in this code is always sRGB. * Cylindrical modification of CIELab colour space
*
* reference: http://www.brucelindbloom.com/index.html?Equations.html * reference: http://www.brucelindbloom.com/index.html?Equations.html
* *
* Created by minjaesong on 16-09-01. * Created by minjaesong on 16-09-01.
@@ -15,7 +16,7 @@ import org.newdawn.slick.Color
object CIELChUtil { object CIELChUtil {
/** Sweet LCh linear gradient */ /** Sweet LCh_ab linear gradient */
fun getGradient(scale: Float, fromCol: Color, toCol: Color): Color { fun getGradient(scale: Float, fromCol: Color, toCol: Color): Color {
val from = fromCol.toLCh() val from = fromCol.toLCh()
val to = toCol.toLCh() val to = toCol.toLCh()
@@ -48,8 +49,8 @@ object CIELChUtil {
return CIELab(L, a, b, alpha) return CIELab(L, a, b, alpha)
} }
private fun Color.toLCh() = this.toXYZ().toLab().toLCh() fun Color.toLCh() = this.toXYZ().toLab().toLCh()
private fun CIELCh.toRGB() = this.toLab().toXYZ().toRGB() fun CIELCh.toRGB() = this.toLab().toXYZ().toRGB()
private fun Float.sqr() = this * this private fun Float.sqr() = this * this
private fun Float.sqrt() = Math.sqrt(this.toDouble()).toFloat() private fun Float.sqrt() = Math.sqrt(this.toDouble()).toFloat()

View File

@@ -4,9 +4,18 @@ import com.jme3.math.FastMath
import org.newdawn.slick.Color import org.newdawn.slick.Color
/** /**
* A modification of CIEXYZ that is useful for surface colours
*
* If you are trying to mix some colour with other, especially one that
* requires additive mixing (such as illuminant), USE CIELuvUtil, this is
* not for you.
*
* RGB in this code is always sRGB. * RGB in this code is always sRGB.
* reference: http://www.brucelindbloom.com/index.html?Equations.html * reference: http://www.brucelindbloom.com/index.html?Equations.html
* *
* If you're using Mac, you can play around with this colour space with
* ColorSync Utility's calculator.
*
* Created by minjaesong on 16-09-01. * Created by minjaesong on 16-09-01.
*/ */
object CIELabUtil { object CIELabUtil {
@@ -38,10 +47,12 @@ object CIELabUtil {
return CIELab(newL, newA, newB, newAlpha).toRGB() return CIELab(newL, newA, newB, newAlpha).toRGB()
} }
private fun Color.toLab() = this.toXYZ().toLab() fun Color.toLab() = this.toXYZ().toLab()
private fun CIELab.toRGB() = this.toXYZ().toRGB() fun RGB.toLab() = this.toXYZ().toLab()
fun CIELab.toRGB() = this.toXYZ().toRGB()
fun CIELab.toRawRGB() = this.toXYZ().toRawRGB()
fun Color.toXYZ(): CIEXYZ { fun RGB.toXYZ(): CIEXYZ {
val newR = if (r > 0.04045f) val newR = if (r > 0.04045f)
((r + 0.055f) / 1.055f).powerOf(2.4f) ((r + 0.055f) / 1.055f).powerOf(2.4f)
else r / 12.92f else r / 12.92f
@@ -56,13 +67,15 @@ object CIELabUtil {
val y = 0.2126729f * newR + 0.7151522f * newG + 0.0721750f * newB val y = 0.2126729f * newR + 0.7151522f * newG + 0.0721750f * newB
val z = 0.0193339f * newR + 0.1191920f * newG + 0.9503041f * newB val z = 0.0193339f * newR + 0.1191920f * newG + 0.9503041f * newB
return CIEXYZ(x, y, z, a) return CIEXYZ(x, y, z, alpha)
} }
fun CIEXYZ.toRGB(): Color { fun Color.toXYZ(): CIEXYZ = RGB(this).toXYZ()
var r = 3.2404542f * x - 1.5371385f * y - 0.4985314f * z
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z fun CIEXYZ.toRawRGB(): RGB {
var b = 0.0556434f * x - 0.2040259f * y + 1.0572252f * z var r = 3.2404542f * X - 1.5371385f * Y - 0.4985314f * Z
var g = -0.9692660f * X + 1.8760108f * Y + 0.0415560f * Z
var b = 0.0556434f * X - 0.2040259f * Y + 1.0572252f * Z
if (r > 0.0031308f) if (r > 0.0031308f)
r = 1.055f * r.powerOf(1f / 2.4f) - 0.055f r = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
@@ -77,13 +90,18 @@ object CIELabUtil {
else else
b *= 12.92f b *= 12.92f
return Color(r, g, b, alpha) return RGB(r, g, b, alpha)
}
fun CIEXYZ.toRGB(): Color {
val rgb = this.toRawRGB()
return Color(rgb.r, rgb.g, rgb.b, rgb.alpha)
} }
fun CIEXYZ.toLab(): CIELab { fun CIEXYZ.toLab(): CIELab {
val x = pivotXYZ(x / whitePoint.x) val x = pivotXYZ(X / D65.X)
val y = pivotXYZ(y / whitePoint.y) val y = pivotXYZ(Y / D65.Y)
val z = pivotXYZ(z / whitePoint.z) val z = pivotXYZ(Z / D65.Z)
val L = Math.max(0f, 116 * y - 16) val L = Math.max(0f, 116 * y - 16)
val a = 500 * (x - y) val a = 500 * (x - y)
@@ -101,23 +119,28 @@ object CIELabUtil {
val z3 = z.cube() val z3 = z.cube()
return CIEXYZ( return CIEXYZ(
whitePoint.x * if (x3 > epsilon) x3 else (x - 16f / 116f) / 7.787f, D65.X * if (x3 > epsilon) x3 else (x - 16f / 116f) / 7.787f,
whitePoint.y * if (L > kappa * epsilon) (L.plus(16f) / 116f).cube() else L / kappa, D65.Y * if (L > kappa * epsilon) (L.plus(16f) / 116f).cube() else L / kappa,
whitePoint.z * if (z3 > epsilon) z3 else (z - 16f / 116f) / 7.787f, D65.Z * if (z3 > epsilon) z3 else (z - 16f / 116f) / 7.787f,
alpha alpha
) )
} }
private fun pivotXYZ(n: Float) = if (n > epsilon) n.cbrt() else (kappa * n + 16f) / 116f private fun pivotXYZ(n: Float) = if (n > epsilon) n.cbrt() else (kappa * n + 16f) / 116f
val epsilon = 0.008856f
val kappa = 903.3f
val whitePoint = CIEXYZ(95.047f, 100f, 108.883f)
private fun Float.cbrt() = FastMath.pow(this, 1f / 3f) private fun Float.cbrt() = FastMath.pow(this, 1f / 3f)
private fun Float.cube() = this * this * this private fun Float.cube() = this * this * this
private fun Float.powerOf(exp: Float) = FastMath.pow(this, exp) private fun Float.powerOf(exp: Float) = FastMath.pow(this, exp)
} }
data class CIEXYZ(var x: Float = 0f, var y: Float = 0f, var z: Float = 0f, val alpha: Float = 1f) internal val D65 = CIEXYZ(95.047f, 100f, 108.883f)
val epsilon = 216.0.div(24389.0).toFloat()
val kappa = 24389.0.div(27.0).toFloat()
data class CIEXYZ(var X: Float = 0f, var Y: Float = 0f, var Z: Float = 0f, val alpha: Float = 1f)
data class CIELab(var L: Float = 0f, var a: Float = 0f, var b: Float = 0f, val alpha: Float = 1f) data class CIELab(var L: Float = 0f, var a: Float = 0f, var b: Float = 0f, val alpha: Float = 1f)
data class RGB(var r: Float = 0f, var g: Float = 0f, var b: Float = 0f, val alpha: Float = 1f) {
constructor(color: Color) : this() {
r = color.r; g = color.g; b = color.b
}
}

View File

@@ -0,0 +1,102 @@
package net.torvald.colourutil
import com.jme3.math.FastMath
import org.newdawn.slick.Color
import net.torvald.colourutil.CIELabUtil.toXYZ
import net.torvald.colourutil.CIELabUtil.toRawRGB
import net.torvald.colourutil.CIELabUtil.toRGB
/**
* A modification of CIEXYZ that is useful for additive mixtures of lights.
*
* reference: http://www.brucelindbloom.com/index.html?Equations.html
*
* If you're using Mac, you can play around with this colour space with
* ColorSync Utility's calculator.
*
* Created by minjaesong on 16-09-06.
*/
object CIELuvUtil {
fun Color.brighterLuv(scale: Float): Color {
val brighten = scale + 1f
val luv = this.toLuv()
luv.L *= brighten
return luv.toRGB()
}
fun Color.darkerLuv(scale: Float): Color {
val darken = 1f - scale
val luv = this.toLuv()
luv.L *= darken
return luv.toRGB()
}
/**
* Alpha value will be overwritten to 1.0
*/
infix fun Color.additiveLuv(other: Color): Color {
val rgb = RGB(r, g, b) additiveLuv RGB(other.r, other.g, other.b)
return Color(rgb.r, rgb.g, rgb.b, a)
}
/**
* Alpha value will be overwritten to 1.0
*/
infix fun RGB.additiveLuv(other: RGB): RGB {
val thisLuv = this.toXYZ().toLuv()
val otherLuv = other.toXYZ().toLuv()
val newL = 1f - (1f - thisLuv.L) * (1 - otherLuv.L)
val newU = thisLuv.u.times(otherLuv.L / newL) + otherLuv.u.times(otherLuv.L).times(1f - thisLuv.L).div(newL)
val newV = thisLuv.v.times(otherLuv.L / newL) + otherLuv.v.times(otherLuv.L).times(1f - thisLuv.L).div(newL)
return CIELuv(newL, newU, newV).toRawRGB()
}
fun CIEXYZ.toLuv(): CIELuv {
val yRef = Y / D65.Y
val uPrime = 4f * X / (X + 15f * Y + 3f * Z)
val vPrime = 9f * Y / (X + 15f * Y + 3f * Z)
val uRefPrime = 4f * D65.X / (D65.X + 15f * D65.Y + 3f * D65.Z)
val vRefPrime = 9f * D65.Y / (D65.X + 15f * D65.Y + 3f * D65.Z)
val L = if (yRef > epsilon)
116f * yRef.cbrt() - 16f
else
kappa * yRef
val u = 13f * L * (uPrime - uRefPrime)
val v = 13f * L * (vPrime - vRefPrime)
return CIELuv(L, u, v, alpha)
}
fun CIELuv.toXYZ(): CIEXYZ {
val Y = if (L > kappa * epsilon)
L.plus(16f).div(116f).cube()
else
L.div(kappa)
val uRef = 4f * D65.X / (D65.X + 15f * D65.Y + 3f * D65.Z)
val vRef = 9f * D65.Y / (D65.X + 15f * D65.Y + 3f * D65.Z)
val a = (1f / 3f) * (52.times(L) / u.plus(13 * L * uRef)).minus(1f)
val b = -5f * Y
val c = -1f / 3f
val d = Y * (39f.times(L) / v.plus(13f * L * vRef)).minus(5f)
val X = (d - b) / (a - c)
val Z = X * a + b
return CIEXYZ(X, Y, Z, alpha)
}
fun Color.toLuv() = this.toXYZ().toLuv()
fun CIELuv.toRawRGB() = this.toXYZ().toRawRGB()
fun CIELuv.toRGB() = this.toXYZ().toRGB()
private fun Float.cbrt() = FastMath.pow(this, 1f / 3f)
private fun Float.cube() = this * this * this
}
data class CIELuv(var L: Float = 0f, var u: Float = 0f, var v: Float = 0f, val alpha: Float = 1f)

View File

@@ -1,5 +1,7 @@
package net.torvald.point package net.torvald.point
import org.dyn4j.geometry.Vector2
/** /**
* Created by minjaesong on 16-01-15. * Created by minjaesong on 16-01-15.
*/ */
@@ -13,4 +15,35 @@ class Point2d(var x: Double, var y: Double) : Cloneable {
this.x = x this.x = x
this.y = y this.y = y
} }
fun set(other: Point2d) {
this.x = other.x
this.y = other.y
}
/**
* Rotate transform this point, with pivot (0, 0)
* @return new Point2d that is rotated
*/
infix fun rot(deg_delta: Double) = Point2d(
x * Math.cos(deg_delta) - y * Math.sin(deg_delta),
x * Math.sin(deg_delta) + y * Math.cos(deg_delta)
)
fun translate(other: Point2d) {
x += other.x
y += other.y
}
fun translate(tx: Double, ty: Double) {
x += tx
y += ty
}
operator fun plus(other: Point2d) = Point2d(x + other.x, y + other.y)
operator fun minus(other: Point2d) = Point2d(x - other.x, y - other.y)
operator fun times(scalar: Double) = Point2d(x * scalar, y * scalar)
operator fun times(other: Point2d) = Point2d(x * other.x, y * other.y)
operator fun div(scalar: Double) = Point2d(x / scalar, y / scalar)
operator fun div(other: Point2d) = Point2d(x / other.x, y / other.y)
fun toVector() = Vector2(x, y)
} }

View File

@@ -16,6 +16,7 @@ import net.torvald.terrarum.gamemap.GameWorld
import net.torvald.terrarum.gamemap.WorldSimulator import net.torvald.terrarum.gamemap.WorldSimulator
import net.torvald.terrarum.gamemap.WorldTime import net.torvald.terrarum.gamemap.WorldTime
import net.torvald.terrarum.mapdrawer.LightmapRenderer import net.torvald.terrarum.mapdrawer.LightmapRenderer
import net.torvald.terrarum.mapdrawer.LightmapRenderer.constructRGBFromInt
import net.torvald.terrarum.mapdrawer.MapCamera import net.torvald.terrarum.mapdrawer.MapCamera
import net.torvald.terrarum.mapdrawer.MapDrawer import net.torvald.terrarum.mapdrawer.MapDrawer
import net.torvald.terrarum.mapgenerator.WorldGenerator import net.torvald.terrarum.mapgenerator.WorldGenerator
@@ -121,8 +122,8 @@ constructor() : BasicGameState() {
// add new player and put it to actorContainer // add new player and put it to actorContainer
//player = PBSigrid.create() player = PBSigrid.create()
player = PBCynthia.create() //player = PBCynthia.create()
//player.setNoClip(true); //player.setNoClip(true);
addActor(player) addActor(player)
@@ -177,7 +178,11 @@ constructor() : BasicGameState() {
WeatherMixer.update(gc, delta) WeatherMixer.update(gc, delta)
TileStats.update() TileStats.update()
if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride) if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride)
world.globalLight = globalLightByTime.toInt() world.globalLight = constructRGBFromInt(
globalLightByTime.redByte,
globalLightByTime.greenByte,
globalLightByTime.blueByte
)
/////////////////////////// ///////////////////////////
@@ -438,7 +443,9 @@ constructor() : BasicGameState() {
} }
// inactivate distant actors // inactivate distant actors
else if (actor is Visible && !actor.inUpdateRange()) { else if (actor is Visible && !actor.inUpdateRange()) {
actorContainerInactive.add(actor) // naïve add; duplicates are checked when the actor is re-activated if (actor !is Projectile) { // if it's a projectile, just kill it.
actorContainerInactive.add(actor) // naïve add; duplicates are checked when the actor is re-activated
}
actorContainer.removeAt(actorIndex) actorContainer.removeAt(actorIndex)
actorContainerSize -= 1 actorContainerSize -= 1
i-- // array removed 1 elem, so we also decrement counter by 1 i-- // array removed 1 elem, so we also decrement counter by 1
@@ -570,3 +577,5 @@ constructor() : BasicGameState() {
return -(low + 1) // key not found return -(low + 1) // key not found
} }
} }
fun Color.toInt() = redByte.shl(16) or greenByte.shl(8) or blueByte

View File

@@ -1,8 +1,14 @@
package net.torvald.terrarum package net.torvald.terrarum
import net.torvald.CSVFetcher
import net.torvald.colourutil.CIELabUtil.toXYZ import net.torvald.colourutil.CIELabUtil.toXYZ
import net.torvald.colourutil.CIELabUtil.toLab import net.torvald.colourutil.CIELabUtil.toLab
import net.torvald.colourutil.CIELabUtil.toRGB import net.torvald.colourutil.CIELabUtil.toRGB
import net.torvald.colourutil.CIELuv
import net.torvald.colourutil.CIELuvUtil.toRawRGB
import net.torvald.colourutil.CIELuvUtil.toLuv
import net.torvald.colourutil.RGB
import org.apache.commons.csv.CSVRecord
import org.newdawn.slick.Color import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics import org.newdawn.slick.Graphics
@@ -13,14 +19,22 @@ import org.newdawn.slick.state.StateBasedGame
* Created by minjaesong on 16-09-05. * Created by minjaesong on 16-09-05.
*/ */
class StateTestingSandbox : BasicGameState() { class StateTestingSandbox : BasicGameState() {
val colRGB = Color(0x51621D)
val colAfter1 = colRGB.toXYZ().toRGB()
//val colAfter2 = colRGB.toXYZ().toLab().toXYZ().toRGB()
override fun init(container: GameContainer?, game: StateBasedGame?) { override fun init(container: GameContainer?, game: StateBasedGame?) {
println("Color:\n$colRGB") val records = CSVFetcher("./src/net/torvald/terrarum/tileproperties/tileprop_10bcol.csv")
println("Color -> XYZ -> Color:\n$colAfter1") records.forEach {
//println("Color -> XYZ -> Lab -> XYZ -> Color:\n$colAfter2") val tenOpacity = intVal(it, "opacity")
val tenLum = intVal(it, "lumcolor")
val eightOpacity = tenOpacity.and(0xff) or
tenOpacity.ushr(10).and(0xff).shl(8) or
tenOpacity.ushr(20).and(0xff).shl(16)
val eightLum = tenLum.and(0xff) or
tenLum.ushr(10).and(0xff).shl(8) or
tenLum.ushr(20).and(0xff).shl(16)
println("$eightOpacity\t$eightLum")
}
} }
override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) { override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
@@ -31,4 +45,15 @@ class StateTestingSandbox : BasicGameState() {
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) { override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
} }
private fun intVal(rec: CSVRecord, s: String): Int {
var ret = -1
try {
ret = Integer.decode(rec.get(s))!!
}
catch (e: NullPointerException) {
}
return ret
}
} }

View File

@@ -0,0 +1,27 @@
package net.torvald.terrarum
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.state.BasicGameState
import org.newdawn.slick.state.StateBasedGame
/**
* ComputerCraft/OpenComputers like-alike, just for fun!
*
* Created by minjaesong on 16-09-07.
*/
class StateVTTest : BasicGameState() {
override fun init(container: GameContainer?, game: StateBasedGame?) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getID() = Terrarum.STATE_ID_TEST_TTY
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}

View File

@@ -193,6 +193,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
val STATE_ID_CONFIG_CALIBRATE = 0x11 val STATE_ID_CONFIG_CALIBRATE = 0x11
val STATE_ID_TEST_FONT = 0x100 val STATE_ID_TEST_FONT = 0x100
val STATE_ID_TEST_TTY = 0x110
val STATE_ID_TEST_SHIT = 0x5617 val STATE_ID_TEST_SHIT = 0x5617
var hasController = false var hasController = false

View File

@@ -38,6 +38,8 @@ object CommandDict {
Pair("help", Help()), Pair("help", Help()),
Pair("version", Version()), Pair("version", Version()),
Pair("seed", Seed()), Pair("seed", Seed()),
Pair("testgetlight", TestGetLight()),
Pair("println", EchoConsole()),
// Test codes // Test codes
Pair("bulletintest", SetBulletin()), Pair("bulletintest", SetBulletin()),

View File

@@ -0,0 +1,33 @@
package net.torvald.terrarum.console
/**
* Created by minjaesong on 16-09-07.
*/
class EchoConsole : ConsoleCommand {
/**
* Args 0: command given
* Args 1: first argument
*
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
*/
override fun execute(args: Array<String>) {
val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]})
argsWoHeader.forEach { execute(it) }
}
fun execute(single_line: String) {
val sb = StringBuilder()
for (ch in single_line) {
if (ch == '\n') {
println(sb.toString())
sb.delete(0, sb.length - 1)
}
else
sb.append(ch)
}
println(sb.toString())
}
override fun printUsage() {
}
}

View File

@@ -0,0 +1,24 @@
package net.torvald.terrarum.console
import net.torvald.terrarum.mapdrawer.LightmapRenderer
/**
* Created by minjaesong on 16-09-07.
*/
class TestGetLight : ConsoleCommand {
/**
* Args 0: command given
* Args 1: first argument
*
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
*/
override fun execute(args: Array<String>) {
val x = args[1].toInt()
val y = args[2].toInt()
val l = LightmapRenderer.getLightRawPos(16, 16)
EchoConsole().execute(l.toString())
}
override fun printUsage() {
}
}

View File

@@ -79,5 +79,5 @@ object AVKey {
const val _PLAYER_QUICKBARSEL = "__quickbarselection" const val __PLAYER_QUICKBARSEL = "__quickbarselection"
} }

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.gameactors package net.torvald.terrarum.gameactors
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.point.Point2d
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.gamemap.GameWorld import net.torvald.terrarum.gamemap.GameWorld
import net.torvald.terrarum.mapdrawer.MapDrawer import net.torvald.terrarum.mapdrawer.MapDrawer
@@ -36,6 +37,7 @@ open class ActorWithBody : Actor(), Visible {
/** /**
* * Position: top-left point * * Position: top-left point
* * Unit: pixel * * Unit: pixel
* !! external class should not hitbox.set(); use setHitboxDimension() and setPosition()
*/ */
override val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0) override val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
@Transient val nextHitbox = Hitbox(0.0, 0.0, 0.0, 0.0) @Transient val nextHitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
@@ -261,6 +263,13 @@ open class ActorWithBody : Actor(), Visible {
baseHitboxH * scale) baseHitboxH * scale)
} }
val centrePosition: Vector2
get() = Vector2(hitbox.centeredX, hitbox.centeredY)
val centrePosPoint: Point2d
get() = Point2d(hitbox.centeredX, hitbox.centeredY)
val feetPosition: Vector2
get() = Vector2(hitbox.centeredX, hitbox.posY + hitbox.height)
override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA) override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA)
/** /**
@@ -325,8 +334,10 @@ open class ActorWithBody : Actor(), Visible {
* If and only if: * If and only if:
* This body is NON-STATIC and the other body is STATIC * This body is NON-STATIC and the other body is STATIC
*/ */
displaceByCCD() if (!isPlayerNoClip) {
applyNormalForce() displaceByCCD()
applyNormalForce()
}
setHorizontalFriction() setHorizontalFriction()
if (isPlayerNoClip) // or hanging on the rope, etc. if (isPlayerNoClip) // or hanging on the rope, etc.
@@ -342,6 +353,10 @@ open class ActorWithBody : Actor(), Visible {
// cheap solution for sticking into the wall while Left or Right is held // cheap solution for sticking into the wall while Left or Right is held
walledLeft = isTouchingSide(nextHitbox, COLLIDING_LEFT) walledLeft = isTouchingSide(nextHitbox, COLLIDING_LEFT)
walledRight = isTouchingSide(nextHitbox, COLLIDING_RIGHT) walledRight = isTouchingSide(nextHitbox, COLLIDING_RIGHT)
if (isPlayerNoClip) {
walledLeft = false
walledRight = false
}
} }
} }
@@ -428,7 +443,8 @@ open class ActorWithBody : Actor(), Visible {
else if (moveDelta.y < 0.0) { // or was moving upward? else if (moveDelta.y < 0.0) { // or was moving upward?
grounded = false grounded = false
if (isTouchingSide(nextHitbox, COLLIDING_TOP)) { // actor hit something on its top if (isTouchingSide(nextHitbox, COLLIDING_TOP)) { // actor hit something on its top
hitAndForciblyReflectY() //hitAndForciblyReflectY()
hitAndReflectY()
} }
else { // the actor is not grounded at all else { // the actor is not grounded at all
} }
@@ -491,6 +507,7 @@ open class ActorWithBody : Actor(), Visible {
} }
} }
@Deprecated("it's no use!")
private fun hitAndForciblyReflectY() { private fun hitAndForciblyReflectY() {
if (veloY.abs() * CEILING_HIT_ELASTICITY > A_PIXEL) if (veloY.abs() * CEILING_HIT_ELASTICITY > A_PIXEL)
veloY = -veloY * CEILING_HIT_ELASTICITY veloY = -veloY * CEILING_HIT_ELASTICITY

View File

@@ -12,7 +12,7 @@ object PBCynthia {
val p: Player = Player() val p: Player = Player()
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json") CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0 p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
p.actorValue["__selectedtile"] = 16 p.actorValue["__selectedtile"] = 16

View File

@@ -58,6 +58,7 @@ object PBSigrid {
p.actorValue[AVKey.BASEDEFENCE] = 141 p.actorValue[AVKey.BASEDEFENCE] = 141
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
p.actorValue["__selectedtile"] = 16 // test code; replace with <tile_item>.primaryUse(gc, delta) p.actorValue["__selectedtile"] = 16 // test code; replace with <tile_item>.primaryUse(gc, delta)
p.actorValue["__aimhelper"] = true p.actorValue["__aimhelper"] = true

View File

@@ -18,7 +18,7 @@ object PlayerBuilder {
// attach sprite // attach sprite
// do etc. // do etc.
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0 p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
return p return p
} }

View File

@@ -0,0 +1,9 @@
package net.torvald.terrarum.gameactors
/**
* Projectile marker. Used to kill them when they're far away from the player, instead of making them sleep.
*
* Created by minjaesong on 16-09-05.
*/
interface Projectile {
}

View File

@@ -8,8 +8,8 @@ import org.dyn4j.geometry.Vector2
class ProjectileHoming( class ProjectileHoming(
type: Int, type: Int,
fromPoint: Vector2, // projected coord fromPoint: Vector2, // projected coord
toPoint: Vector2, // arriving coord toPoint: Vector2 // arriving coord
override var luminosity: Int = 0) : ProjectileSimple(type, fromPoint, toPoint, luminosity) { ) : ProjectileSimple(type, fromPoint, toPoint) {

View File

@@ -1,7 +1,9 @@
package net.torvald.terrarum.gameactors package net.torvald.terrarum.gameactors
import net.torvald.colourutil.CIELabUtil.brighterLab import net.torvald.colourutil.CIELabUtil.darkerLab
import net.torvald.point.Point2d
import net.torvald.spriteanimation.SpriteAnimation import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.Terrarum
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
import org.newdawn.slick.Color import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer import org.newdawn.slick.GameContainer
@@ -14,16 +16,21 @@ import java.util.*
* Created by minjaesong on 16-08-29. * Created by minjaesong on 16-08-29.
*/ */
open class ProjectileSimple( open class ProjectileSimple(
type: Int, private val type: Int,
fromPoint: Vector2, // projected coord fromPoint: Vector2, // projected coord
toPoint: Vector2, // arriving coord toPoint: Vector2 // arriving coord
override var luminosity: Int = 0) : ActorWithBody(), Luminous { ) : ActorWithBody(), Luminous, Projectile {
val damage: Int val damage: Int
val displayColour: Color val displayColour: Color
/** scalar part of velocity */ /** scalar part of velocity */
val speed: Int val speed: Int
override var luminosity: Int
get() = bulletDatabase[type][OFFSET_LUMINOSITY] as Int
set(value) {
}
/** /**
* Arguments: * Arguments:
* *
@@ -32,8 +39,14 @@ open class ProjectileSimple(
*/ */
override val lightBoxList = ArrayList<Hitbox>() override val lightBoxList = ArrayList<Hitbox>()
val lifetimeMax = 2500
var lifetimeCounter = 0
val posPre: Point2d
init { init {
hitbox.set(fromPoint.x, fromPoint.y, 2.0, 2.0) // 2.0: size of the hitbox in pixels setPosition(fromPoint.x, fromPoint.y)
posPre = Point2d(fromPoint.x, fromPoint.y)
// lightbox sized 8x8 centered to the bullet // lightbox sized 8x8 centered to the bullet
lightBoxList.add(Hitbox(-4.0, -4.0, 8.0, 8.0)) lightBoxList.add(Hitbox(-4.0, -4.0, 8.0, 8.0))
this.velocity.set(velocity) this.velocity.set(velocity)
@@ -43,16 +56,10 @@ open class ProjectileSimple(
isNoSubjectToGrav = bulletDatabase[type][OFFSET_NOGRAVITY] as Boolean isNoSubjectToGrav = bulletDatabase[type][OFFSET_NOGRAVITY] as Boolean
speed = bulletDatabase[type][OFFSET_SPEED] as Int speed = bulletDatabase[type][OFFSET_SPEED] as Int
if (displayColour == Color(254, 0, 0, 0)) { setHitboxDimension(2, 2, 0, 0) // should be following sprite's properties if there IS one
sprite = bulletDatabase[type][OFFSET_SPRITE] as SpriteAnimation
}
velocity.set((fromPoint to toPoint).setMagnitude(speed.toDouble()))
val initVelo = Vector2(speed.toDouble(), 0.0)
initVelo.setDirection((fromPoint to toPoint).direction)
velocity.set(initVelo)
@@ -61,34 +68,42 @@ open class ProjectileSimple(
override fun update(gc: GameContainer, delta: Int) { override fun update(gc: GameContainer, delta: Int) {
// hit something and despawn // hit something and despawn
if (ccdCollided || grounded) flagDespawn() lifetimeCounter += delta
if ((ccdCollided || grounded) || lifetimeCounter >= lifetimeMax) flagDespawn()
posPre.set(centrePosPoint)
super.update(gc, delta) super.update(gc, delta)
} }
override fun drawBody(gc: GameContainer, g: Graphics) { override fun drawBody(gc: GameContainer, g: Graphics) {
val colourTail = displayColour.darker(0f) // clone a colour
colourTail.a = 0.16f
// draw trail of solid colour (Terraria style maybe?) // draw trail of solid colour (Terraria style maybe?)
g.lineWidth = 3f g.lineWidth = 2f * Terrarum.ingame.screenZoom
g.drawGradientLine( g.drawGradientLine(
nextHitbox.centeredX.toFloat(), hitbox.centeredX.toFloat() * Terrarum.ingame.screenZoom,
nextHitbox.centeredY.toFloat(), hitbox.centeredY.toFloat() * Terrarum.ingame.screenZoom,
displayColour, displayColour,
hitbox.centeredX.toFloat(), posPre.x.toFloat() * Terrarum.ingame.screenZoom,
hitbox.centeredY.toFloat(), posPre.y.toFloat() * Terrarum.ingame.screenZoom,
displayColour.brighterLab(0.8f) colourTail
) )
} }
override fun drawGlow(gc: GameContainer, g: Graphics) = drawBody(gc, g)
companion object { companion object {
val OFFSET_DAMAGE = 0 val OFFSET_DAMAGE = 0
val OFFSET_COL = 1 // set it to Color(254, 0, 0, 0) to use sprite val OFFSET_COL = 1 // Color or SpriteAnimation
val OFFSET_NOGRAVITY = 2 val OFFSET_NOGRAVITY = 2
val OFFSET_SPEED = 3 val OFFSET_SPEED = 3
val OFFSET_SPRITE = 4 val OFFSET_LUMINOSITY = 4
val bulletDatabase = arrayOf( val bulletDatabase = arrayOf(
// damage, display colour, no gravity, speed // damage, display colour, no gravity, speed
arrayOf(7, Color(0xFF5429), true, 50), arrayOf(7, Color(0xFF5429), true, 40, 32),
arrayOf(8, Color(0xFF5429), true, 50) arrayOf(8, Color(0xFF5429), true, 20, 0)
// ... // ...
) )
} }

View File

@@ -5,9 +5,11 @@ import net.torvald.terrarum.gameactors.Player
import net.torvald.terrarum.mapdrawer.MapCamera import net.torvald.terrarum.mapdrawer.MapCamera
import net.torvald.terrarum.mapdrawer.MapDrawer import net.torvald.terrarum.mapdrawer.MapDrawer
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.ProjectileSimple
import net.torvald.terrarum.tileproperties.TileNameCode import net.torvald.terrarum.tileproperties.TileNameCode
import net.torvald.terrarum.tileproperties.TilePropCodex import net.torvald.terrarum.tileproperties.TilePropCodex
import net.torvald.terrarum.ui.UIHandler import net.torvald.terrarum.ui.UIHandler
import org.dyn4j.geometry.Vector2
import org.newdawn.slick.Input import org.newdawn.slick.Input
/** /**
@@ -15,10 +17,16 @@ import org.newdawn.slick.Input
*/ */
object GameController { object GameController {
fun processInput(input: Input) { val mouseX: Float
val mouseTileX = ((MapCamera.cameraX + input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt() get() = (MapCamera.cameraX + Terrarum.appgc.input.mouseX / Terrarum.ingame.screenZoom)
val mouseTileY = ((MapCamera.cameraY + input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt() val mouseY: Float
get() = (MapCamera.cameraY + Terrarum.appgc.input.mouseY / Terrarum.ingame.screenZoom)
val mouseTileX: Int
get() = (mouseX / MapDrawer.TILE_SIZE).toInt()
val mouseTileY: Int
get() = (mouseY / MapDrawer.TILE_SIZE).toInt()
fun processInput(input: Input) {
KeyToggler.update(input) KeyToggler.update(input)
@@ -48,6 +56,7 @@ object GameController {
catch (e: ArrayIndexOutOfBoundsException) { catch (e: ArrayIndexOutOfBoundsException) {
} }
} }
else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
// test tile place // test tile place
@@ -100,7 +109,13 @@ object GameController {
} }
fun mousePressed(button: Int, x: Int, y: Int) { fun mousePressed(button: Int, x: Int, y: Int) {
if (button == 0) {
Terrarum.ingame.addActor(ProjectileSimple(
0,
Terrarum.ingame.player.centrePosition,
Vector2(mouseX.toDouble(), mouseY.toDouble())
))
}
} }
fun mouseReleased(button: Int, x: Int, y: Int) { fun mouseReleased(button: Int, x: Int, y: Int) {

View File

@@ -7,7 +7,7 @@ import org.newdawn.slick.Color
* Created by minjaesong on 16-07-08. * Created by minjaesong on 16-07-08.
*/ */
class Light10B { /*class Light10B {
private var data = 0 private var data = 0
@@ -192,4 +192,4 @@ class Light10B {
(this.rawG() + other.rawG()).clampChannel() , (this.rawG() + other.rawG()).clampChannel() ,
(this.rawB() + other.rawB()).clampChannel() (this.rawB() + other.rawB()).clampChannel()
) )
} }*/

View File

@@ -4,12 +4,13 @@ import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.tileproperties.TilePropCodex import net.torvald.terrarum.tileproperties.TilePropCodex
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.colourutil.RGB
import net.torvald.colourutil.CIELuvUtil.additiveLuv
import net.torvald.terrarum.gameactors.Visible import net.torvald.terrarum.gameactors.Visible
import net.torvald.terrarum.tileproperties.TileNameCode import net.torvald.terrarum.tileproperties.TileNameCode
import net.torvald.terrarum.tileproperties.TilePropUtil import net.torvald.terrarum.tileproperties.TilePropUtil
import org.newdawn.slick.Color import org.newdawn.slick.Color
import org.newdawn.slick.Graphics import org.newdawn.slick.Graphics
import org.newdawn.slick.Image
import java.util.* import java.util.*
/** /**
@@ -41,7 +42,7 @@ object LightmapRenderer {
// color model related constants // color model related constants
const val MUL = 1024 // modify this to 1024 to implement 30-bit RGB const val MUL = 1024 // modify this to 1024 to implement 30-bit RGB
const val CHANNEL_MAX_DECIMAL = 4f const val CHANNEL_MAX_DECIMAL = 1f
const val MUL_2 = MUL * MUL const val MUL_2 = MUL * MUL
const val CHANNEL_MAX = MUL - 1 const val CHANNEL_MAX = MUL - 1
const val CHANNEL_MAX_FLOAT = CHANNEL_MAX.toFloat() const val CHANNEL_MAX_FLOAT = CHANNEL_MAX.toFloat()
@@ -52,6 +53,8 @@ object LightmapRenderer {
internal var for_x_end: Int = 0 internal var for_x_end: Int = 0
internal var for_y_end: Int = 0 internal var for_y_end: Int = 0
fun getLightRawPos(x: Int, y: Int) = lightmap[y][x]
fun getLight(x: Int, y: Int): Int? { fun getLight(x: Int, y: Int): Int? {
/*if (x !in 0..Terrarum.game.map.width - 1 || y !in 0..Terrarum.game.map.height - 1) /*if (x !in 0..Terrarum.game.map.width - 1 || y !in 0..Terrarum.game.map.height - 1)
// if out of range then // if out of range then
@@ -240,11 +243,11 @@ object LightmapRenderer {
lightLevelThis = sunLight lightLevelThis = sunLight
} }
// luminous tile on top of air // luminous tile on top of air
else if (thisWall == AIR && thisTileLuminosity.toInt() > 0) { else if (thisWall == AIR && thisTileLuminosity > 0) {
lightLevelThis = sunLight maxBlend thisTileLuminosity // maximise to not exceed 1.0 with normal (<= 1.0) light lightLevelThis = sunLight maxBlend thisTileLuminosity // maximise to not exceed 1.0 with normal (<= 1.0) light
} }
// opaque wall and luminous tile // opaque wall and luminous tile
else if (thisWall != AIR && thisTileLuminosity.toInt() > 0) { else if (thisWall != AIR && thisTileLuminosity > 0) {
lightLevelThis = thisTileLuminosity lightLevelThis = thisTileLuminosity
} }
// END MIX TILE // END MIX TILE
@@ -278,7 +281,7 @@ object LightmapRenderer {
} }
else if (xoff != 0 && yoff != 0) { else if (xoff != 0 && yoff != 0) {
// 'a' tiles // 'a' tiles
nearby = darkenUniformInt(getLight(x + xoff, y + yoff) ?: 0, 12) //2 for 40step nearby = darkenUniformInt(getLight(x + xoff, y + yoff) ?: 0, 12)
// mix some to have more 'spreading' // mix some to have more 'spreading'
// so that light spreads in a shape of an octagon instead of a diamond // so that light spreads in a shape of an octagon instead of a diamond
} }
@@ -290,8 +293,7 @@ object LightmapRenderer {
} }
} }
ambient = darkenColoured(ambient, ambient = darkenColoured(ambient, thisTileOpacity) // get real ambient by appling opacity value
thisTileOpacity) // get real ambient by appling opacity value
// mix and return lightlevel and ambient // mix and return lightlevel and ambient
return lightLevelThis maxBlend ambient return lightLevelThis maxBlend ambient
@@ -371,7 +373,7 @@ object LightmapRenderer {
for (iy in 0..1) { for (iy in 0..1) {
for (ix in 0..1) { for (ix in 0..1) {
g.color = Color(colourMapItoL[iy * 2 + ix].rgb30ClampTo24()) g.color = colourMapItoL[iy * 2 + ix].normaliseToColour()
g.fillRect( g.fillRect(
(x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round() (x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round()
@@ -398,7 +400,7 @@ object LightmapRenderer {
if (x + sameLevelCounter >= this_x_end) break if (x + sameLevelCounter >= this_x_end) break
} }
g.color = Color((getLight(x, y) ?: 0).rgb30ClampTo24()) g.color = (getLight(x, y) ?: 0).normaliseToColour()
g.fillRect( g.fillRect(
(x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
(y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(), (y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
@@ -434,9 +436,9 @@ object LightmapRenderer {
if (darken.toInt() < 0 || darken.toInt() >= COLOUR_RANGE_SIZE) if (darken.toInt() < 0 || darken.toInt() >= COLOUR_RANGE_SIZE)
throw IllegalArgumentException("darken: out of range ($darken)") throw IllegalArgumentException("darken: out of range ($darken)")
val r = data.r() * (1f - darken.r() * 6) // 6: Arbitrary value val r = data.r() * (1f - darken.r() * 4f)
val g = data.g() * (1f - darken.g() * 6) // TODO gamma correction? val g = data.g() * (1f - darken.g() * 4f)
val b = data.b() * (1f - darken.b() * 6) val b = data.b() * (1f - darken.b() * 4f)
return constructRGBFromFloat(r.clampZero(), g.clampZero(), b.clampZero()) return constructRGBFromFloat(r.clampZero(), g.clampZero(), b.clampZero())
} }
@@ -452,9 +454,9 @@ object LightmapRenderer {
if (brighten.toInt() < 0 || brighten.toInt() >= COLOUR_RANGE_SIZE) if (brighten.toInt() < 0 || brighten.toInt() >= COLOUR_RANGE_SIZE)
throw IllegalArgumentException("brighten: out of range ($brighten)") throw IllegalArgumentException("brighten: out of range ($brighten)")
val r = data.r() * (1f + brighten.r() * 6) // 6: Arbitrary value val r = data.r() * (1f + brighten.r() * 4f)
val g = data.g() * (1f + brighten.g() * 6) // TODO gamma correction? val g = data.g() * (1f + brighten.g() * 4f)
val b = data.b() * (1f + brighten.b() * 6) val b = data.b() * (1f + brighten.b() * 4f)
return constructRGBFromFloat(r.clampChannel(), g.clampChannel(), b.clampChannel()) return constructRGBFromFloat(r.clampChannel(), g.clampChannel(), b.clampChannel())
} }
@@ -498,29 +500,44 @@ object LightmapRenderer {
* @return * @return
*/ */
private infix fun Int.maxBlend(other: Int): Int { private infix fun Int.maxBlend(other: Int): Int {
val r1 = this.rawR() val r1 = this.rawR(); val r2 = other.rawR(); val newR = if (r1 > r2) r1 else r2
val r2 = other.rawR() val g1 = this.rawG(); val g2 = other.rawG(); val newG = if (g1 > g2) g1 else g2
val newR = if (r1 > r2) r1 else r2 val b1 = this.rawB(); val b2 = other.rawB(); val newB = if (b1 > b2) b1 else b2
val g1 = this.rawG()
val g2 = other.rawG()
val newG = if (g1 > g2) g1 else g2
val b1 = this.rawB()
val b2 = other.rawB()
val newB = if (b1 > b2) b1 else b2
return constructRGBFromInt(newR, newG, newB) return constructRGBFromInt(newR, newG, newB)
} }
// TODO LUT of 1024 entries (int resulting light, int rectified light)
val compLut = floatArrayOf(0f, 0.61328125f, 0.6875f, 0.68359375f, 0.66015625f, 0.62109375f, 0.56640625f, 0.515625f, 0.46484375f, 0.40625f, 0.3515625f, 0.29296875f, 0.234375f, 0.17578125f, 0.1171875f, 0.0546875f, 0f)
fun getComp(lum: Float) = FastMath.interpolateLinear(
lum.mod(1f / compLut.size),
compLut[lum.times(compLut.size).toInt() / compLut.size],
compLut[lum.times(compLut.size).toInt() / compLut.size + 1])
/**
* Deprecated: Fuck it, this vittupää just doesn't want to work
*/
private infix fun Int.screenBlend(other: Int): Int { private infix fun Int.screenBlend(other: Int): Int {
val r1 = this.r() /*val r1 = this.r(); val r2 = other.r(); val newR = 1 - (1 - r1) * (1 - r2)
val r2 = other.r() val g1 = this.g(); val g2 = other.g(); val newG = 1 - (1 - g1) * (1 - g2)
val newR = 1 - (1 - r1) * (1 - r2) val b1 = this.b(); val b2 = other.b(); val newB = 1 - (1 - b1) * (1 - b2)*/
val g1 = this.g()
val g2 = other.g() val r1 = this.r(); val r2 = other.r()
val newG = 1 - (1 - g1) * (1 - g2) val g1 = this.g(); val g2 = other.g()
val b1 = this.b() val b1 = this.b(); val b2 = other.b()
val b2 = other.b()
val newB = 1 - (1 - b1) * (1 - b2) var screenR = 1f - (1f - r1).clampZero() * (1f - r2).clampZero()
var screenG = 1f - (1f - g1).clampZero() * (1f - g2).clampZero()
var screenB = 1f - (1f - b1).clampZero() * (1f - b2).clampZero()
// hax.
val addR = if (r1 > r2) r1 else r2
val addG = if (g1 > g2) g1 else g2
val addB = if (b1 > b2) b1 else b2
val newR = Math.min(screenR, addR)
val newG = Math.min(screenG, addG)
val newB = Math.min(screenB, addB)
return constructRGBFromFloat(newR, newG, newB) return constructRGBFromFloat(newR, newG, newB)
} }
@@ -541,6 +558,7 @@ object LightmapRenderer {
fun Int.rawG() = this % MUL_2 / MUL fun Int.rawG() = this % MUL_2 / MUL
fun Int.rawB() = this % MUL fun Int.rawB() = this % MUL
/** 0.0 - 1.0 for 0-1023 (0.0 - 0.25 for 0-255) */
fun Int.r(): Float = this.rawR() / CHANNEL_MAX_FLOAT fun Int.r(): Float = this.rawR() / CHANNEL_MAX_FLOAT
fun Int.g(): Float = this.rawG() / CHANNEL_MAX_FLOAT fun Int.g(): Float = this.rawG() / CHANNEL_MAX_FLOAT
fun Int.b(): Float = this.rawB() / CHANNEL_MAX_FLOAT fun Int.b(): Float = this.rawB() / CHANNEL_MAX_FLOAT
@@ -570,17 +588,17 @@ object LightmapRenderer {
if (r !in 0..CHANNEL_MAX) throw IllegalArgumentException("Red: out of range ($r)") if (r !in 0..CHANNEL_MAX) throw IllegalArgumentException("Red: out of range ($r)")
if (g !in 0..CHANNEL_MAX) throw IllegalArgumentException("Green: out of range ($g)") if (g !in 0..CHANNEL_MAX) throw IllegalArgumentException("Green: out of range ($g)")
if (b !in 0..CHANNEL_MAX) throw IllegalArgumentException("Blue: out of range ($b)") if (b !in 0..CHANNEL_MAX) throw IllegalArgumentException("Blue: out of range ($b)")
return (r * MUL_2 + g * MUL + b) return r * MUL_2 + g * MUL + b
} }
fun constructRGBFromFloat(r: Float, g: Float, b: Float): Int { fun constructRGBFromFloat(r: Float, g: Float, b: Float): Int {
if (r < 0 || r > 1.0f) throw IllegalArgumentException("Red: out of range ($r)") if (r < 0 || r > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Red: out of range ($r)")
if (g < 0 || g > 1.0f) throw IllegalArgumentException("Green: out of range ($g)") if (g < 0 || g > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Green: out of range ($g)")
if (b < 0 || b > 1.0f) throw IllegalArgumentException("Blue: out of range ($b)") if (b < 0 || b > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Blue: out of range ($b)")
val intR = (r * CHANNEL_MAX).floor() val intR = (r * CHANNEL_MAX).round()
val intG = (g * CHANNEL_MAX).floor() val intG = (g * CHANNEL_MAX).round()
val intB = (b * CHANNEL_MAX).floor() val intB = (b * CHANNEL_MAX).round()
return constructRGBFromInt(intR, intG, intB) return constructRGBFromInt(intR, intG, intB)
} }
@@ -622,14 +640,6 @@ object LightmapRenderer {
private fun Int.clamp256() = if (this > 255) 255 else this private fun Int.clamp256() = if (this > 255) 255 else this
fun Int.rgb30ClampTo24(): Int {
val r = this.rawR().clamp256()
val g = this.rawG().clamp256()
val b = this.rawB().clamp256()
return r.shl(16) or g.shl(8) or b
}
infix fun Float.powerOf(f: Float) = FastMath.pow(this, f) infix fun Float.powerOf(f: Float) = FastMath.pow(this, f)
private fun Float.sqr() = this * this private fun Float.sqr() = this * this
private fun Float.sqrt() = FastMath.sqrt(this) private fun Float.sqrt() = FastMath.sqrt(this)
@@ -641,6 +651,11 @@ object LightmapRenderer {
fun Float.ceil() = FastMath.ceil(this) fun Float.ceil() = FastMath.ceil(this)
fun Int.even(): Boolean = this and 1 == 0 fun Int.even(): Boolean = this and 1 == 0
fun Int.odd(): Boolean = this and 1 == 1 fun Int.odd(): Boolean = this and 1 == 1
fun Int.normaliseToColour(): Color = Color(
Math.min(this.rawR(), 256),
Math.min(this.rawG(), 256),
Math.min(this.rawB(), 256)
)
data class Lantern(val posX: Int, val posY: Int, val luminosity: Int) data class Lantern(val posX: Int, val posY: Int, val luminosity: Int)

View File

@@ -33,9 +33,8 @@ object TilePropCodex {
println("[TilePropCodex] Building tile properties table") println("[TilePropCodex] Building tile properties table")
records.forEach { record -> setProp( records.forEach { setProp(
tileProps[idDamageToIndex(intVal(record, "id"), intVal(record, "dmg"))] tileProps[idDamageToIndex(intVal(it, "id"), intVal(it, "dmg"))], it)
, record)
} }
} }
catch (e: IOException) { catch (e: IOException) {

View File

@@ -5,7 +5,9 @@ import net.torvald.random.HQRNG
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gamemap.WorldTime import net.torvald.terrarum.gamemap.WorldTime
import net.torvald.terrarum.mapdrawer.LightmapRenderer import net.torvald.terrarum.mapdrawer.LightmapRenderer
import net.torvald.terrarum.toInt
import net.torvald.terrarum.weather.WeatherMixer import net.torvald.terrarum.weather.WeatherMixer
import org.newdawn.slick.Color
/** /**
* Created by minjaesong on 16-06-16. * Created by minjaesong on 16-06-16.

View File

@@ -127,7 +127,7 @@
## Notes ## ## Notes ##
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky # Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
# Opacity/Lumcolor: 30-bit RGB. Light diffusers have a value of ZERO. # Opacity/Lumcolor: 30-bit RGB. Only the light diffusers have a opacity value of ZERO.
# Solid: whether the tile has full collision # Solid: whether the tile has full collision
# movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed # movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed
# dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l] # dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l]
Can't render this file because it contains an unexpected character in line 1 and column 18.

View File

@@ -0,0 +1,156 @@
"id";"dmg";"name" ; "opacity";"strength";"dsty";"fluid";"solid";"wall";"lumcolor";"drop";"ddmg";"fall";"dlfn";"friction"
"0"; "0";"TILE_AIR" ; "526344"; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"4"
"1"; "0";"TILE_STONE" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "0"; "0"; "0";"16"
"1"; "1";"TILE_STONE_QUARRIED" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "1"; "0"; "0";"16"
"1"; "2";"TILE_STONE_TILE_WHITE" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "2"; "0"; "0";"16"
"1"; "3";"TILE_STONE_BRICKS" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "3"; "0"; "0";"16"
"2"; "0";"TILE_DIRT" ; "2105376"; "6";"1400"; "0"; "1"; "1"; "0"; "2"; "0"; "0"; "0";"16"
"2"; "1";"TILE_GRASS" ; "2105376"; "6";"1400"; "0"; "1"; "1"; "0"; "2"; "1"; "0"; "0";"16"
"3"; "0";"TILE_PLANK_NORMAL" ; "2105376"; "12"; "740"; "0"; "1"; "1"; "0"; "3"; "0"; "0"; "0";"16"
"3"; "1";"TILE_PLANK_EBONY" ; "2105376"; "12";"1200"; "0"; "1"; "1"; "0"; "3"; "1"; "0"; "0";"16"
"3"; "2";"TILE_PLANK_BIRCH" ; "2105376"; "12"; "670"; "0"; "1"; "1"; "0"; "3"; "2"; "0"; "0";"16"
"3"; "3";"TILE_PLANK_BLOODROSE" ; "2105376"; "12"; "900"; "0"; "1"; "1"; "0"; "3"; "3"; "0"; "0";"16"
"4"; "0";"TILE_TRUNK_NORMAL" ; "2105376"; "12"; "740"; "0"; "1"; "0"; "0"; "3"; "0"; "0"; "0";"16"
"4"; "1";"TILE_TRUNK_EBONY" ; "2105376"; "12";"1200"; "0"; "1"; "0"; "0"; "3"; "1"; "0"; "0";"16"
"4"; "2";"TILE_TRUNK_BIRCH" ; "2105376"; "12"; "670"; "0"; "1"; "0"; "0"; "3"; "2"; "0"; "0";"16"
"4"; "3";"TILE_TRUNK_BLOODROSE" ; "2105376"; "12"; "900"; "0"; "1"; "0"; "0"; "3"; "3"; "0"; "0";"16"
"5"; "0";"TILE_SAND" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "0"; "1"; "0";"16"
"5"; "1";"TILE_SAND_WHITE" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "1"; "1"; "0";"16"
"5"; "2";"TILE_SAND_RED" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "2"; "1"; "0";"16"
"5"; "3";"TILE_SAND_DESERT" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "3"; "1"; "0";"16"
"5"; "4";"TILE_SAND_BLACK" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "4"; "1"; "0";"16"
"5"; "5";"TILE_SAND_GREEN" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "5"; "1"; "0";"16"
"6"; "0";"TILE_GRAVEL" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "6"; "0"; "1"; "0";"16"
"6"; "1";"TILE_GRAVEL_GREY" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "6"; "1"; "1"; "0";"16"
"7"; "0";"TILE_ORE_MALACHITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "0"; "0"; "0";"16"
"7"; "1";"TILE_ORE_HEMATITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "1"; "0"; "0";"16"
"7"; "2";"TILE_ORE_NATURAL_GOLD" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "2"; "0"; "0";"16"
"7"; "3";"TILE_ORE_NATURAL_SILVER" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "3"; "0"; "0";"16"
"7"; "4";"TILE_ORE_RUTILE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "4"; "0"; "0";"16"
"7"; "5";"TILE_ORE_AURICHALCUMITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "5"; "0"; "0";"16"
"8"; "0";"TILE_GEM_RUBY" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "0"; "0"; "0";"16"
"8"; "1";"TILE_GEM_EMERALD" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "1"; "0"; "0";"16"
"8"; "2";"TILE_GEM_SAPPHIRE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "2"; "0"; "0";"16"
"8"; "3";"TILE_GEM_TOPAZ" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "3"; "0"; "0";"16"
"8"; "4";"TILE_GEM_DIAMOND" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "4"; "0"; "0";"16"
"8"; "5";"TILE_GEM_AMETHYST" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "5"; "0"; "0";"16"
"9"; "0";"TILE_SNOW" ; "2105376"; "6"; "500"; "0"; "1"; "1"; "0"; "9"; "0"; "0"; "0";"16"
"9"; "1";"TILE_ICE_FRAGILE" ; "855309"; "1"; "930"; "0"; "1"; "0"; "0"; "9"; "1"; "0"; "0";"16"
"9"; "2";"TILE_ICE_NATURAL" ; "1710618"; "25"; "930"; "0"; "1"; "1"; "0"; "9"; "2"; "0"; "0"; "8"
"9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "2105376"; "25";"3720"; "0"; "1"; "1"; "1253434"; "9"; "3"; "0"; "0"; "8"
"9"; "4";"TILE_GLASS_CRUDE" ; "196867"; "1";"2500"; "0"; "1"; "1"; "0"; "9"; "4"; "0"; "0";"16"
"9"; "5";"TILE_GLASS_CLEAN" ; "65793"; "1";"2203"; "0"; "1"; "1"; "0"; "9"; "5"; "0"; "0";"16"
"10"; "0";"TILE_PLATFORM_STONE" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "0"; "0"; "0";"16"
"10"; "1";"TILE_PLATFORM_WOODEN" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "1"; "0"; "0";"16"
"10"; "2";"TILE_PLATFORM_EBONY" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "2"; "0"; "0";"16"
"10"; "3";"TILE_PLATFORM_BIRCH" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "3"; "0"; "0";"16"
"10"; "4";"TILE_PLATFORM_BLOODROSE" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "4"; "0"; "0";"16"
"11"; "0";"TILE_TORCH" ; "526344"; "0"; "N/A"; "0"; "0"; "0";"16674864"; "11"; "0"; "0"; "1";"16"
"11"; "1";"TILE_TORCH_FROST" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "5143807"; "11"; "1"; "0"; "1";"16"
"12"; "0";"TILE_TORCH" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "0"; "0"; "0";"16"
"12"; "1";"TILE_TORCH_FROST" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "1"; "0"; "0";"16"
"13"; "0";"TILE_ILLUMINATOR_WHITE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15003370"; "13"; "0"; "0"; "0";"16"
"13"; "1";"TILE_ILLUMINATOR_YELLOW" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"16766720"; "13"; "1"; "0"; "0";"16"
"13"; "2";"TILE_ILLUMINATOR_ORANGE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"16751616"; "13"; "2"; "0"; "0";"16"
"13"; "3";"TILE_ILLUMINATOR_RED" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15400960"; "13"; "3"; "0"; "0";"16"
"13"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15401143"; "13"; "4"; "0"; "0";"16"
"13"; "5";"TILE_ILLUMINATOR_PURPLE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"11993323"; "13"; "5"; "0"; "0";"16"
"13"; "6";"TILE_ILLUMINATOR_BLUE" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "13311"; "13"; "6"; "0"; "0";"16"
"13"; "7";"TILE_ILLUMINATOR_CYAN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "55039"; "13"; "7"; "0"; "0";"16"
"13"; "8";"TILE_ILLUMINATOR_GREEN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "3604224"; "13"; "8"; "0"; "0";"16"
"13"; "9";"TILE_ILLUMINATOR_GREEN_DARK"; "526344"; "0"; "N/A"; "0"; "1"; "1"; "2123776"; "13"; "9"; "0"; "0";"16"
"13"; "10";"TILE_ILLUMINATOR_BROWN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "5578752"; "13"; "10"; "0"; "0";"16"
"13"; "11";"TILE_ILLUMINATOR_TAN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "9857076"; "13"; "11"; "0"; "0";"16"
"13"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "526344"; "0"; "N/A"; "0"; "1"; "1";"12434877"; "13"; "12"; "0"; "0";"16"
"13"; "13";"TILE_ILLUMINATOR_GREY_MED" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "7697781"; "13"; "13"; "0"; "0";"16"
"13"; "14";"TILE_ILLUMINATOR_GREY_DARK" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "4276545"; "13"; "14"; "0"; "0";"16"
"13"; "15";"TILE_ILLUMINATOR_BLACK" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "7274751"; "13"; "15"; "0"; "0";"16"
"14"; "0";"TILE_ILLUMINATOR_WHITE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "0"; "0"; "0";"16"
"14"; "1";"TILE_ILLUMINATOR_YELLOW" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "1"; "0"; "0";"16"
"14"; "2";"TILE_ILLUMINATOR_ORANGE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "2"; "0"; "0";"16"
"14"; "3";"TILE_ILLUMINATOR_RED" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "3"; "0"; "0";"16"
"14"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "4"; "0"; "0";"16"
"14"; "5";"TILE_ILLUMINATOR_PURPLE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "5"; "0"; "0";"16"
"14"; "6";"TILE_ILLUMINATOR_BLUE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "6"; "0"; "0";"16"
"14"; "7";"TILE_ILLUMINATOR_CYAN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "7"; "0"; "0";"16"
"14"; "8";"TILE_ILLUMINATOR_GREEN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "8"; "0"; "0";"16"
"14"; "9";"TILE_ILLUMINATOR_GREEN_DARK"; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "9"; "0"; "0";"16"
"14"; "10";"TILE_ILLUMINATOR_BROWN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "10"; "0"; "0";"16"
"14"; "11";"TILE_ILLUMINATOR_TAN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "11"; "0"; "0";"16"
"14"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "12"; "0"; "0";"16"
"14"; "13";"TILE_ILLUMINATOR_GREY_MED" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "13"; "0"; "0";"16"
"14"; "14";"TILE_ILLUMINATOR_GREY_DARK" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "14"; "0"; "0";"16"
"14"; "15";"TILE_ILLUMINATOR_BLACK" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "15"; "0"; "0";"16"
"15"; "0";"TILE_SANDSTONE" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "0"; "0"; "0";"16"
"15"; "1";"TILE_SANDSTONE_WHITE" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "1"; "0"; "0";"16"
"15"; "2";"TILE_SANDSTONE_RED" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "2"; "0"; "0";"16"
"15"; "3";"TILE_SANDSTONE_DESERT" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "3"; "0"; "0";"16"
"15"; "4";"TILE_SANDSTONE_BLACK" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "4"; "0"; "0";"16"
"15"; "5";"TILE_SANDSTONE_BLACK" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "5"; "0"; "0";"16"
"16"; "0";"TILE_LANTERN_IRON_REGULAR" ; "526344"; "0"; "N/A"; "0"; "0"; "0";"16674864"; "16"; "0"; "0"; "0";"16"
"16"; "1";"TILE_SUNSTONE" ; "2105376"; "0"; "N/A"; "0"; "1"; "0"; "0"; "16"; "1"; "0"; "2";"16"
"16"; "2";"TILE_DAYLIGHT_CAPACITOR" ; "2105376"; "0"; "N/A"; "0"; "1"; "0"; "0"; "16"; "2"; "0"; "3";"16"
"254"; "0";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "1";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "2";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "3";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "4";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "5";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "6";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "7";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "8";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "9";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "10";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "11";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "12";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "13";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "14";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"254"; "15";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "0";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "1";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "2";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "3";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "4";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "5";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "6";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "7";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "8";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "9";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "10";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "11";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "12";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "13";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "14";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"255"; "15";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
"256"; "0";"TILE_NULL" ; "0"; "-1";"2600"; "0"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
## Notes ##
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
# Opacity/Lumcolor: 24-bit RGB. Only the light diffusers have a opacity value of ZERO.
# Solid: whether the tile has full collision
# movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed
# dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l]
# dlfn: dynamic luminosity function.
# 0-static, 1-torch flicker, 2-current global light (sun, star, moon), 3-daylight at noon,
# 4-slow breath, 5-pulsate
## Illuminators ##
# Illuminator white: RGB(228,238,234), simulation of a halophosphate FL lamp (If you want high CRI lamp, collect a daylight!)
# Defalut torch : L 64 a 51 b 59; real candlelight colour taken from properly configured camera.
# Sunstone: Artificial sunlight, change colour over time in sync with sunlight. The light is set by game's code.
# Sunlight capacitor: daylight at noon. Set by game's code.
## Tiles ##
# 16 colour palette : Old Apple Macintosh 16-colour palette
# Magical ice: theoretical __metallic__ ice that might form under super-high pressure (> 5 TPa). Its density is a wild guess.
## References ##
# * Density of various woods : http://www.engineeringtoolbox.com/wood-density-d_40.html
# * Density of various phases of ice : http://www1.lsbu.ac.uk/water/ice_phases.html
Can't render this file because it contains an unexpected character in line 1 and column 18.

View File

@@ -34,7 +34,7 @@ class UIPieMenu : UICanvas {
override fun update(gc: GameContainer, delta: Int) { override fun update(gc: GameContainer, delta: Int) {
if (selection >= 0) if (selection >= 0)
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] =
selection % slotCount selection % slotCount

View File

@@ -24,8 +24,8 @@ class UIQuickBar : UICanvas, MouseControlled {
override var handler: UIHandler? = null override var handler: UIHandler? = null
private var selection: Int private var selection: Int
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey._PLAYER_QUICKBARSEL)!! get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKBARSEL)!!
set(value) { Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = value } set(value) { Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] = value }
override fun update(gc: GameContainer, delta: Int) { override fun update(gc: GameContainer, delta: Int) {
} }

View File

@@ -7,7 +7,6 @@ import net.torvald.colourutil.ColourUtil
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gamemap.WorldTime import net.torvald.terrarum.gamemap.WorldTime
import net.torvald.terrarum.mapdrawer.Light10B
import org.newdawn.slick.Color import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics import org.newdawn.slick.Graphics
@@ -32,7 +31,7 @@ object WeatherMixer {
private var skyBoxCurrent = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) private var skyBoxCurrent = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
private var skyBoxNext = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) private var skyBoxNext = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
val globalLightNow = Light10B(0) val globalLightNow = Color(0)
// Weather indices // Weather indices
const val WEATHER_GENERIC = "generic" const val WEATHER_GENERIC = "generic"
@@ -91,11 +90,14 @@ object WeatherMixer {
g.fill(skyBoxCurrent, skyColourFill) g.fill(skyBoxCurrent, skyColourFill)
// calculate global light // calculate global light
globalLightNow.fromSlickColor(getGradientColour(lightColourMap, 0, timeNow)) val gradCol = getGradientColour(lightColourMap, 0, timeNow)
globalLightNow.r = gradCol.r
globalLightNow.g = gradCol.g
globalLightNow.b = gradCol.b
} }
fun getGlobalLightOfTime(timeInSec: Int): Light10B = fun getGlobalLightOfTime(timeInSec: Int): Color =
Light10B(getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec)) getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec)
fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color { fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color {
val dataPointDistance = WorldTime.DAY_LENGTH / image.width val dataPointDistance = WorldTime.DAY_LENGTH / image.width