mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 00:26:07 +09:00
fallable blocks actually falls
This commit is contained in:
@@ -141,6 +141,9 @@
|
|||||||
# fv: vertical friction (boolean)
|
# fv: vertical friction (boolean)
|
||||||
# fr: horizontal friction. 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
# 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 ##
|
## Illuminators ##
|
||||||
#
|
#
|
||||||
|
|||||||
|
@@ -46,7 +46,7 @@ class BlockProp {
|
|||||||
|
|
||||||
var drop: Int = 0
|
var drop: Int = 0
|
||||||
|
|
||||||
var maxSupport: Int? = null
|
var maxSupport: Int = -1 // couldn't use NULL at all...
|
||||||
|
|
||||||
var friction: Int = 0
|
var friction: Int = 0
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import net.torvald.aa.KDTree
|
import net.torvald.aa.KDTree
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.blockproperties.Fluid
|
import net.torvald.terrarum.blockproperties.Fluid
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
@@ -41,9 +42,13 @@ object WorldSimulator {
|
|||||||
|
|
||||||
// END OF FLUID-RELATED STUFFS
|
// END OF FLUID-RELATED STUFFS
|
||||||
|
|
||||||
|
/** Top-left point */
|
||||||
var updateXFrom = 0
|
var updateXFrom = 0
|
||||||
|
/** Bottom-right point */
|
||||||
var updateXTo = 0
|
var updateXTo = 0
|
||||||
|
/** Top-left point */
|
||||||
var updateYFrom = 0
|
var updateYFrom = 0
|
||||||
|
/** Bottom-right point */
|
||||||
var updateYTo = 0
|
var updateYTo = 0
|
||||||
|
|
||||||
val colourNone = Color(0x808080FF.toInt())
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user