aboutsummaryrefslogtreecommitdiff
path: root/src/objs
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-03-20 20:16:31 +0100
committerne_mene <[email protected]>2026-03-20 20:16:31 +0100
commita18546961d3d00548b8e7e30125d72f932ee8623 (patch)
tree6156245d449fc1a0eef4197ea1b4f6cc6a96ad58 /src/objs
parent9ccef5fa8cfdc142a95713dadc66e8f562c9ea75 (diff)
particle spawn shapes
Diffstat (limited to 'src/objs')
-rw-r--r--src/objs/specks.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/objs/specks.lua b/src/objs/specks.lua
index 7bd3c78..5044c9c 100644
--- a/src/objs/specks.lua
+++ b/src/objs/specks.lua
@@ -1,6 +1,24 @@
Speck_Sys = {}
Speck_Sys.__index = Speck_Sys
+function speck_shape_rectangle(speck_sys)
+ local w = (speck_sys.spawn_width or 0) / 2
+ local h = (speck_sys.spawn_height or 0) / 2
+
+ return randf_range(-w, w), randf_range(-h, h)
+end
+
+function speck_shape_point(speck_sys)
+ return 0, 0
+end
+
+function speck_shape_circle(speck_sys)
+ local angle = randf_range(0, math.pi * 2)
+ local r = speck_sys.spawn_radius or 0
+ r = r * lmath.random()
+ return r*math.cos(angle), r*math.sin(angle)
+end
+
function Speck_Sys.new()
local self = setmetatable({}, Speck_Sys)
@@ -20,6 +38,8 @@ function Speck_Sys.new()
self.free_ids = {}
self.free_ids_size = 0
+ self.spawn_shape = speck_shape_point
+
self.spawn_amount_min = 1
self.spawn_amount_max = 1
@@ -79,7 +99,8 @@ function Speck_Sys:spawn_particles()
data.alive[id] = true
- data.pos[id] = { x = self.x, y = self.y }
+ local offx, offy = self.spawn_shape(self)
+ data.pos[id] = { x = self.x + offx, y = self.y + offy }
data.vel[id] = { x = self.initial_velx, y = self.initial_vely }
local beta = self.spread * math.pi / 180