mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
bigger torch flame sprite; basic physics on particles
This commit is contained in:
@@ -15,7 +15,7 @@ import org.dyn4j.geometry.Vector2
|
||||
*
|
||||
* Created by minjaesong on 2017-01-20.
|
||||
*/
|
||||
open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision: Boolean, maxLifeTime: Second? = null) : Runnable {
|
||||
open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision: Boolean, val noCollision: Boolean = true, maxLifeTime: Second? = null) : Runnable {
|
||||
|
||||
/** Will NOT actually delete from the CircularArray */
|
||||
@Volatile var flagDespawn = false
|
||||
@@ -44,15 +44,20 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
|
||||
open fun update(delta: Float) {
|
||||
if (!flagDespawn) {
|
||||
lifetimeCounter += delta
|
||||
if (despawnUponCollision) {
|
||||
if (velocity.isZero ||
|
||||
// simple stuck check
|
||||
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(
|
||||
hitbox.canonicalX.div(TerrarumAppConfiguration.TILE_SIZE).floorInt(),
|
||||
hitbox.canonicalY.div(TerrarumAppConfiguration.TILE_SIZE).floorInt()
|
||||
) ?: Block.STONE].isSolid) {
|
||||
flagDespawn = true
|
||||
}
|
||||
if (velocity.isZero ||
|
||||
// simple stuck check
|
||||
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(
|
||||
hitbox.centeredX.div(TerrarumAppConfiguration.TILE_SIZE).floorInt(),
|
||||
hitbox.startY.div(TerrarumAppConfiguration.TILE_SIZE).floorInt()
|
||||
)].isSolid ||
|
||||
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(
|
||||
hitbox.centeredX.div(TerrarumAppConfiguration.TILE_SIZE).floorInt(),
|
||||
hitbox.endY.div(TerrarumAppConfiguration.TILE_SIZE).floorInt()
|
||||
)].isSolid) {
|
||||
|
||||
|
||||
if (despawnUponCollision) flagDespawn = true
|
||||
if (!noCollision) velocity.y = 0.0
|
||||
}
|
||||
|
||||
if (lifetimeCounter >= lifetimeMax) {
|
||||
|
||||
Reference in New Issue
Block a user