CIELab and CIELch colour util

Former-commit-id: f8b0413223c2c968e4627e7c251220d32e2c6bf5
Former-commit-id: 2bce3479a8ad95ac06fbbd6c35cf73967a49568d
This commit is contained in:
Song Minjae
2016-09-01 21:36:44 +09:00
parent 6e51b0c751
commit b735335a99
10 changed files with 228 additions and 53 deletions

View File

@@ -186,9 +186,9 @@ open class ActorWithBody : Actor(), Visible {
@Transient internal val BASE_FRICTION = 0.3
@Transient val KINEMATIC = 1 // does not be budged by external forces
@Transient val DYNAMIC = 2
@Transient val STATIC = 3 // does not be budged by external forces, target of collision
@Transient val KINEMATIC = 1 // does not displaced by external forces
@Transient val DYNAMIC = 2 // displaced by external forces
@Transient val STATIC = 3 // does not displaced by external forces, target of collision
var collisionType = DYNAMIC
@Transient private val CCD_TICK = 1.0 / 16.0
@@ -214,7 +214,11 @@ open class ActorWithBody : Actor(), Visible {
internal var walledLeft = false
internal var walledRight = false
/**
* true: This actor had just made collision
*/
var ccdCollided = false
private set
var isWalkingH = false
var isWalkingV = false
@@ -945,6 +949,8 @@ open class ActorWithBody : Actor(), Visible {
assertPrinted = true
}
internal fun flagDespawn() { flagDespawn = true }
companion object {
@Transient private val TSIZE = MapDrawer.TILE_SIZE

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.gameactors
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.colourutil.CIELabUtil.brighterLab
import org.dyn4j.geometry.Vector2
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
@@ -34,18 +34,28 @@ open class ProjectileSimple(
damage = bulletDatabase[type][0] as Int
displayColour = bulletDatabase[type][1] as Color
collisionType = KINEMATIC
}
override fun update(gc: GameContainer, delta: Int) {
// hit something and despawn! (use ```flagDespawn = true```)
// hit something and despawn
if (ccdCollided) flagDespawn()
super.update(gc, delta)
}
override fun drawBody(gc: GameContainer, g: Graphics) {
// draw trail of solid colour (Terraria style maybe?)
g.lineWidth = 3f
g.drawGradientLine(
nextHitbox.centeredX.toFloat(),
nextHitbox.centeredY.toFloat(),
displayColour,
hitbox.centeredX.toFloat(),
hitbox.centeredY.toFloat(),
displayColour.brighterLab(0.8f)
)
}
companion object {