mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
Finally fixed CIELabUtil's anomaly; apparently past me was dumb fucking perkeleen vittupää
Former-commit-id: 731df40639ccf1463238f70dd615bd1771eee259 Former-commit-id: fdf00fbe30f876731d9d952b2a65f448b90c7913
This commit is contained in:
@@ -15,7 +15,7 @@ import org.newdawn.slick.Color
|
|||||||
|
|
||||||
object CIELChUtil {
|
object CIELChUtil {
|
||||||
|
|
||||||
/** Sweet Lch linear gradient */
|
/** Sweet LCh 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()
|
||||||
|
|||||||
@@ -60,20 +60,20 @@ object CIELabUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CIEXYZ.toRGB(): Color {
|
fun CIEXYZ.toRGB(): Color {
|
||||||
var r = 3.2404542f * x + -1.5371385f * y + -0.4985314f * z
|
var r = 3.2404542f * x - 1.5371385f * y - 0.4985314f * z
|
||||||
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z
|
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z
|
||||||
var b = 0.0556434f * x + -0.2040259f * y + 1.0572252f * 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
|
||||||
else
|
else
|
||||||
r *= 12.92f
|
r *= 12.92f
|
||||||
if (g > 0.0031308f)
|
if (g > 0.0031308f)
|
||||||
g = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
g = 1.055f * g.powerOf(1f / 2.4f) - 0.055f
|
||||||
else
|
else
|
||||||
g *= 12.92f
|
g *= 12.92f
|
||||||
if (b > 0.0031308f)
|
if (b > 0.0031308f)
|
||||||
b = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
b = 1.055f * b.powerOf(1f / 2.4f) - 0.055f
|
||||||
else
|
else
|
||||||
b *= 12.92f
|
b *= 12.92f
|
||||||
|
|
||||||
|
|||||||
34
src/net/torvald/terrarum/StateTestingSandbox.kt
Normal file
34
src/net/torvald/terrarum/StateTestingSandbox.kt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import net.torvald.colourutil.CIELabUtil.toXYZ
|
||||||
|
import net.torvald.colourutil.CIELabUtil.toLab
|
||||||
|
import net.torvald.colourutil.CIELabUtil.toRGB
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.state.BasicGameState
|
||||||
|
import org.newdawn.slick.state.StateBasedGame
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-09-05.
|
||||||
|
*/
|
||||||
|
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?) {
|
||||||
|
println("Color:\n$colRGB")
|
||||||
|
println("Color -> XYZ -> Color:\n$colAfter1")
|
||||||
|
//println("Color -> XYZ -> Lab -> XYZ -> Color:\n$colAfter2")
|
||||||
|
}
|
||||||
|
|
||||||
|
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_SHIT
|
||||||
|
|
||||||
|
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,6 +99,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
|
|
||||||
gc.graphics.clear() // clean up any 'dust' in the buffer
|
gc.graphics.clear() // clean up any 'dust' in the buffer
|
||||||
|
|
||||||
|
//addState(StateTestingSandbox())
|
||||||
//addState(StateSplash())
|
//addState(StateSplash())
|
||||||
//addState(StateMonitorCheck())
|
//addState(StateMonitorCheck())
|
||||||
//addState(StateFontTester())
|
//addState(StateFontTester())
|
||||||
@@ -192,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_SHIT = 0x5617
|
||||||
|
|
||||||
var hasController = false
|
var hasController = false
|
||||||
val CONTROLLER_DEADZONE = 0.1f
|
val CONTROLLER_DEADZONE = 0.1f
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import org.dyn4j.geometry.Vector2
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-08-29.
|
* Created by minjaesong on 16-08-29.
|
||||||
*/
|
*/
|
||||||
class ProjectileHoming(type: Int, position: Vector2, velocity: Vector2, luminosity: Int = 0) :
|
class ProjectileHoming(
|
||||||
ProjectileSimple(type, position, velocity, luminosity) {
|
type: Int,
|
||||||
|
fromPoint: Vector2, // projected coord
|
||||||
|
toPoint: Vector2, // arriving coord
|
||||||
|
override var luminosity: Int = 0) : ProjectileSimple(type, fromPoint, toPoint, luminosity) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import net.torvald.colourutil.CIELabUtil.brighterLab
|
import net.torvald.colourutil.CIELabUtil.brighterLab
|
||||||
|
import net.torvald.spriteanimation.SpriteAnimation
|
||||||
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
|
||||||
@@ -8,16 +9,20 @@ import org.newdawn.slick.Graphics
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Simplest projectile.
|
||||||
|
*
|
||||||
* Created by minjaesong on 16-08-29.
|
* Created by minjaesong on 16-08-29.
|
||||||
*/
|
*/
|
||||||
open class ProjectileSimple(
|
open class ProjectileSimple(
|
||||||
type: Int,
|
type: Int,
|
||||||
position: Vector2,
|
fromPoint: Vector2, // projected coord
|
||||||
velocity: Vector2,
|
toPoint: Vector2, // arriving coord
|
||||||
override var luminosity: Int = 0) : ActorWithBody(), Luminous {
|
override var luminosity: Int = 0) : ActorWithBody(), Luminous {
|
||||||
|
|
||||||
val damage: Int
|
val damage: Int
|
||||||
val displayColour: Color
|
val displayColour: Color
|
||||||
|
/** scalar part of velocity */
|
||||||
|
val speed: Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@@ -28,19 +33,35 @@ open class ProjectileSimple(
|
|||||||
override val lightBoxList = ArrayList<Hitbox>()
|
override val lightBoxList = ArrayList<Hitbox>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
hitbox.set(position.x, position.y, 2.0, 2.0) // 2.0: size of the hitbox in pixels
|
hitbox.set(fromPoint.x, fromPoint.y, 2.0, 2.0) // 2.0: size of the hitbox in pixels
|
||||||
lightBoxList.add(Hitbox(0.0, 0.0, 2.0, 2.0))
|
// lightbox sized 8x8 centered to the bullet
|
||||||
|
lightBoxList.add(Hitbox(-4.0, -4.0, 8.0, 8.0))
|
||||||
this.velocity.set(velocity)
|
this.velocity.set(velocity)
|
||||||
|
|
||||||
damage = bulletDatabase[type][0] as Int
|
damage = bulletDatabase[type][OFFSET_DAMAGE] as Int
|
||||||
displayColour = bulletDatabase[type][1] as Color
|
displayColour = bulletDatabase[type][OFFSET_COL] as Color
|
||||||
|
isNoSubjectToGrav = bulletDatabase[type][OFFSET_NOGRAVITY] as Boolean
|
||||||
|
speed = bulletDatabase[type][OFFSET_SPEED] as Int
|
||||||
|
|
||||||
|
if (displayColour == Color(254, 0, 0, 0)) {
|
||||||
|
sprite = bulletDatabase[type][OFFSET_SPRITE] as SpriteAnimation
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
val initVelo = Vector2(speed.toDouble(), 0.0)
|
||||||
|
initVelo.setDirection((fromPoint to toPoint).direction)
|
||||||
|
|
||||||
|
velocity.set(initVelo)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
collisionType = KINEMATIC
|
collisionType = KINEMATIC
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
// hit something and despawn
|
// hit something and despawn
|
||||||
if (ccdCollided) flagDespawn()
|
if (ccdCollided || grounded) flagDespawn()
|
||||||
|
|
||||||
super.update(gc, delta)
|
super.update(gc, delta)
|
||||||
}
|
}
|
||||||
@@ -59,11 +80,15 @@ open class ProjectileSimple(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TYPE_BULLET_BASIC = 0
|
val OFFSET_DAMAGE = 0
|
||||||
|
val OFFSET_COL = 1 // set it to Color(254, 0, 0, 0) to use sprite
|
||||||
|
val OFFSET_NOGRAVITY = 2
|
||||||
|
val OFFSET_SPEED = 3
|
||||||
|
val OFFSET_SPRITE = 4
|
||||||
val bulletDatabase = arrayOf(
|
val bulletDatabase = arrayOf(
|
||||||
arrayOf(7, Color(0xFF5429)),
|
// damage, display colour, no gravity, speed
|
||||||
arrayOf(8, Color(0xFF5429))
|
arrayOf(7, Color(0xFF5429), true, 50),
|
||||||
|
arrayOf(8, Color(0xFF5429), true, 50)
|
||||||
// ...
|
// ...
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ object LightmapRenderer {
|
|||||||
* * true: overscanning is limited to 8 tiles in width (overscan_opaque)
|
* * true: overscanning is limited to 8 tiles in width (overscan_opaque)
|
||||||
* * false: overscanning will fully applied to 32 tiles in width (overscan_open)
|
* * false: overscanning will fully applied to 32 tiles in width (overscan_open)
|
||||||
*/
|
*/
|
||||||
/*val rect_width = for_x_end - for_x_start
|
val rect_width = for_x_end - for_x_start
|
||||||
val rect_height_rem_hbars = for_y_end - for_y_start - 2
|
val rect_height_rem_hbars = for_y_end - for_y_start - 2
|
||||||
val noop_mask = BitSet(2 * (rect_width) +
|
val noop_mask = BitSet(2 * (rect_width) +
|
||||||
2 * (rect_height_rem_hbars))
|
2 * (rect_height_rem_hbars))
|
||||||
@@ -148,11 +148,11 @@ object LightmapRenderer {
|
|||||||
// build noop map
|
// build noop map
|
||||||
for (i in 0..rect_size) {
|
for (i in 0..rect_size) {
|
||||||
val point = edgeToMaskNum(i)
|
val point = edgeToMaskNum(i)
|
||||||
val tile = Terrarum.game.map.getTileFromTerrain(point.first, point.second) ?: TileNameCode.NULL
|
val tile = Terrarum.ingame.world.getTileFromTerrain(point.first, point.second) ?: TileNameCode.NULL
|
||||||
val isSolid = TilePropCodex.getProp(tile).isSolid
|
val isSolid = TilePropCodex.getProp(tile).isSolid
|
||||||
|
|
||||||
noop_mask.set(i, isSolid)
|
noop_mask.set(i, isSolid)
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updating order:
|
* Updating order:
|
||||||
|
|||||||
Reference in New Issue
Block a user