rain megaparticle experiment

This commit is contained in:
minjaesong
2017-12-18 20:45:32 +09:00
parent c5fa83b2f4
commit 941d9fa107
16 changed files with 286 additions and 69 deletions

View File

@@ -15,7 +15,7 @@ import org.dyn4j.geometry.Vector2
*
* Created by minjaesong on 2017-01-20.
*/
open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = null) : Runnable {
open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision: Boolean, maxLifeTime: Second? = null) : Runnable {
/** Will NOT actually delete from the CircularArray */
@Volatile var flagDespawn = false
@@ -41,12 +41,18 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = n
fun update(delta: Float) {
if (!flagDespawn) {
lifetimeCounter += delta
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
// simple stuck check
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
hitbox.canonicalY.div(TILE_SIZE).floorInt()
) ?: Block.STONE].isSolid) {
if (despawnUponCollision) {
if (velocity.isZero ||
// simple stuck check
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
hitbox.canonicalY.div(TILE_SIZE).floorInt()
) ?: Block.STONE].isSolid) {
flagDespawn = true
}
}
if (lifetimeCounter >= lifetimeMax) {
flagDespawn = true
}