From 9656bc79db67e1d7242c0a8d860f5871ad0a10c6 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Tue, 24 Apr 2018 13:42:55 +0200 Subject: [PATCH] animations along path --- cannon.lua | 26 +++++++++++++++++++++++++- util.lua | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cannon.lua b/cannon.lua index a9d2c46..148f1e4 100644 --- a/cannon.lua +++ b/cannon.lua @@ -10,11 +10,35 @@ local register_spacecannon = function(color, range, timeout, speed) visual_size = {x=0.25, y=0.25}, textures = {entity_texture,entity_texture,entity_texture,entity_texture,entity_texture,entity_texture}, collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25}, - physical = false, + physical = false }, + timer = 0, on_step = function(self, dtime) + self.timer = self.timer + dtime local pos = self.object:getpos() + + if self.timer > 0.5 then + -- add sparks along the way + minetest.add_particlespawner({ + amount = 5, + time = 0.5, + minpos = pos, + maxpos = pos, + minvel = {x = -2, y = -2, z = -2}, + maxvel = {x = 2, y = 2, z = 2}, + minacc = {x = -3, y = -3, z = -3}, + maxacc = {x = 3, y = 3, z = 3}, + minexptime = 1, + maxexptime = 2.5, + minsize = 0.5, + maxsize = 0.75, + texture = "spacecannon_spark.png", + glow = 5 + }) + self.timer = 0 + end + local node = minetest.get_node(pos) if node.name == "air" then diff --git a/util.lua b/util.lua index 34b9ad2..e9c92f7 100644 --- a/util.lua +++ b/util.lua @@ -78,6 +78,7 @@ spacecannon.destroy = function(pos,range) minsize = radius * 3, maxsize = radius * 5, texture = "spacecannon_spark.png", + glow = 5 }) minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = math.min(radius * 20, 128)})