diff options
| -rw-r--r-- | src/objs/specks.lua | 23 |
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 |
