pick and hammer spawns particles

This commit is contained in:
minjaesong
2023-10-12 01:47:00 +09:00
parent 00ca1d3e1a
commit 6bf535e968
4 changed files with 78 additions and 2 deletions

View File

@@ -11,10 +11,13 @@ import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.gameitems.mouseInInteractableRangeTools
import net.torvald.terrarum.gameparticles.createRandomBlockParticle
import net.torvald.terrarum.itemproperties.Calculate
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
import org.dyn4j.geometry.Vector2
import kotlin.math.roundToInt
/**
@@ -90,6 +93,17 @@ object PickaxeCore {
if (drop.isNotBlank()) {
INGAME.queueActorAddition(DroppedItem(drop, (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
}
repeat(9) {
val pos = Vector2(
x * TILE_SIZED + 2 + (4 * (it % 3)),
y * TILE_SIZED + 4 + (4 * (it / 3))
)
createRandomBlockParticle(tile, pos, 1.0 * (if (Math.random() < 0.5) -1 else 1)).let {
it.despawnUponCollision = false
(Terrarum.ingame as TerrarumIngame).addParticle(it)
}
}
}
}

View File

@@ -10,10 +10,14 @@ import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.gameitems.mouseInInteractableRangeTools
import net.torvald.terrarum.gameparticles.createRandomBlockParticle
import net.torvald.terrarum.itemproperties.Calculate
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
import net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCore.BASE_MASS_AND_SIZE
import net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCore.TOOL_DURABILITY_BASE
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import org.dyn4j.geometry.Vector2
import kotlin.math.roundToInt
/**
@@ -95,6 +99,18 @@ object SledgehammerCore {
if (drop.isNotBlank()) {
INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
}
repeat(9) {
val pos = Vector2(
x * TILE_SIZED + 2 + (4 * (it % 3)),
y * TILE_SIZED + 4 + (4 * (it / 3))
)
createRandomBlockParticle(wall, pos, 1.0 * (if (Math.random() < 0.5) -1 else 1)).let {
it.despawnUponCollision = false
it.drawColour.set(App.tileMaker.wallOverlayColour)
(Terrarum.ingame as TerrarumIngame).addParticle(it)
}
}
}
}