TNT: add some depth to the explosion effect

We add a dirt-like particle (drawn from scratch, uses some
colors from default_dirt's palette) to spawn many particles
that have collision enabled around the center of the blast.

This has the effect of obscuring the center of the blast, as
that is a painfully visible empty area when the explosion happens,
as there's only a little spark.

The dirt particles bounce around the walls and floor a bit,
and disappear rapidly, well before the smoke particles disappear.

This is a nice visual distraction that obscures the sudden
appearance of the gaping hole, and makes it a whole lot more
believable.
This commit is contained in:
Auke Kok 2016-01-24 23:48:38 -08:00
parent 42dc2ed99c
commit 24e7214097
2 changed files with 30 additions and 2 deletions

View file

@ -146,7 +146,7 @@ local function entity_physics(pos, radius)
end
end
local function add_effects(pos, radius)
local function add_effects(pos, radius, drops)
minetest.add_particlespawner({
amount = 128,
time = 1,
@ -162,6 +162,34 @@ local function add_effects(pos, radius)
maxsize = 16,
texture = "tnt_smoke.png",
})
-- we just dropped some items. Look at the items entities and pick
-- one of them to use as texture
local texture = "tnt_blast.png" --fallback texture
for name, drop in pairs(drops) do
local def = minetest.registered_nodes[name]
if def and def.tiles and def.tiles[1] then
texture = def.tiles[1]
break
end
end
minetest.add_particlespawner({
amount = 64,
time = 0.1,
minpos = vector.subtract(pos, radius / 2),
maxpos = vector.add(pos, radius / 2),
minvel = {x=-3, y=0, z=-3},
maxvel = {x=3, y=5, z=3},
minacc = {x=0, y=-10, z=0},
maxacc = {x=0, y=-10, z=0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = 2,
maxsize = 6,
texture = texture,
collisiondetection = true,
})
end
local function burn(pos)
@ -223,7 +251,7 @@ local function boom(pos)
local drops = explode(pos, radius)
entity_physics(pos, radius)
eject_drops(drops, pos, radius)
add_effects(pos, radius)
add_effects(pos, radius, drops)
end
minetest.register_node("tnt:tnt", {

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B