fallable blocks actually falls

This commit is contained in:
minjaesong
2019-06-25 23:30:22 +09:00
parent 04ea9aec42
commit a45b68b8d5
3 changed files with 37 additions and 1 deletions

View File

@@ -141,6 +141,9 @@
# fv: vertical friction (boolean)
# fr: horizontal friction. 0: frictionless, <16: slippery, 16: regular, >16: sticky
#
# grav: Whether the block should fall through the empty space. N/A to not make it fall;
# 0 to fall immediately (e.g. Sand), nonzero to indicate that number of floating blocks can be supported (e.g. Scaffolding)
#
#
## Illuminators ##
#
1 id drop name shdr shdg shdb shduv str dsty mate solid plat wall grav dlfn fv fr lumr lumg lumb lumuv colour vscs
141 #
142 # # grav: Whether the block should fall through the empty space. N/A to not make it fall
143 ## Illuminators ## # 0 to fall immediately (e.g. Sand), nonzero to indicate that number of floating blocks can be supported (e.g. Scaffolding)
144 #
145 #
146 ## Illuminators ##
147 #
148 # Illuminator white: Mercury Lamp CIELAB of (94, -5.131, 10.613), which is made out of CIEXYZ of (0.947638, 1.146481, 0.482263), measured with ColorMunki Spectrometer (If you don't want green tinge, collect a daylight!)
149 # Illuminator orange: Sodium Lamp CIE xy of (0.5375, 0.4153), CIEXYZ of (352.531139, 272.379377, 30.980339), measured with ColorMunki Spectrometer

View File

@@ -46,7 +46,7 @@ class BlockProp {
var drop: Int = 0
var maxSupport: Int? = null
var maxSupport: Int = -1 // couldn't use NULL at all...
var friction: Int = 0

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import net.torvald.aa.KDTree
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.gameactors.ActorWBMovable
@@ -41,9 +42,13 @@ object WorldSimulator {
// END OF FLUID-RELATED STUFFS
/** Top-left point */
var updateXFrom = 0
/** Bottom-right point */
var updateXTo = 0
/** Top-left point */
var updateYFrom = 0
/** Bottom-right point */
var updateYTo = 0
val colourNone = Color(0x808080FF.toInt())
@@ -272,6 +277,34 @@ object WorldSimulator {
}
}
}*/
// displace fallables (TODO implement blocks with fallable supports e.g. scaffolding)
// only displace SINGLE BOTTOMMOST block on single X-coord (this doesn't mean they must fall only one block)
// so that the "falling" should be visible to the end user
for (x in updateXFrom..updateXTo) {
var fallDownCounter = 0
for (y in updateYTo downTo updateYFrom) {
val currentTile = world.getTileFromTerrain(x, y)
val prop = BlockCodex[currentTile]
val isSolid = prop.isSolid
val support = prop.maxSupport
val isFallable = support != -1
if (fallDownCounter != 0 && isFallable) {
// replace blocks
world.setTileTerrain(x, y, Block.AIR)
world.setTileTerrain(x, y + fallDownCounter, currentTile)
break
}
else if (isSolid) {
fallDownCounter = 0
}
else if (!isSolid && !isFallable) {
fallDownCounter += 1
}
}
}
}