aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-04-13 12:54:40 +0200
committerne_mene <[email protected]>2026-04-13 12:54:40 +0200
commit1bf54519e80c33c4007c044f4c060b109af9d530 (patch)
tree02446e7caa54f3f911f9bbf2b353d62c7fd15732 /src
parent3ee034d0b6533be0e8cb1cb12ff10449641770d1 (diff)
speck rotation
Diffstat (limited to 'src')
-rw-r--r--src/scenes/speck_editor.lua4
-rw-r--r--src/specks.lua19
2 files changed, 22 insertions, 1 deletions
diff --git a/src/scenes/speck_editor.lua b/src/scenes/speck_editor.lua
index 8ed4df9..2598c34 100644
--- a/src/scenes/speck_editor.lua
+++ b/src/scenes/speck_editor.lua
@@ -23,6 +23,10 @@ local PROPERTY_CUSTOM = {
spread = { min = 0, max = 360 },
lifetime_min = { min = 0, max = 32 },
lifetime_max = { min = 0, max = 32 },
+ angle_min = { min = -360, max = 360 },
+ angle_max = { min = -360, max = 360 },
+ angle_vel_min = { min = -720, max = 720 },
+ angle_vel_max = { min = -720, max = 720 },
interval = { min = 0, max = 32, step = 0.01 },
texture_path = { is_file = true, directory = "res/img/" },
gradient = { is_file = true, directory = "res/img/" },
diff --git a/src/specks.lua b/src/specks.lua
index faaa69b..3cc4221 100644
--- a/src/specks.lua
+++ b/src/specks.lua
@@ -33,6 +33,9 @@ function Speck_Sys.new()
lifetime = {},
lifetime_max = {},
+ angle = {},
+ angle_vel = {},
+
scale_start = {},
scale_end = {}
}
@@ -71,6 +74,11 @@ function Speck_Sys.new()
self.interval = 0.1
+ self.angle_min = 0
+ self.angle_max = 0
+ self.angle_vel_min = 0
+ self.angle_vel_max = 0
+
self.texture_path = "res/img/speck.png"
self.x = 0
@@ -100,6 +108,10 @@ SPECK_EXPORTED_ARGS = {
"initial_velx_max",
"initial_vely_min",
"initial_vely_max",
+ "angle_vel_min",
+ "angle_vel_max",
+ "angle_min",
+ "angle_max",
"damping",
"spread",
"lifetime_min",
@@ -152,6 +164,9 @@ function Speck_Sys:spawn_particles()
y = randf_range(self.initial_vely_min, self.initial_vely_max),
}
+ data.angle[id] = randf_range(self.angle_min, self.angle_max)
+ data.angle_vel[id] = randf_range(self.angle_vel_min, self.angle_vel_max)
+
local beta = self.spread * math.pi / 180
beta = beta / 2
beta = randf_range(-beta, beta)
@@ -209,6 +224,8 @@ function Speck_Sys:update(dt)
data.vel[i].x = data.vel[i].x + (dampx + self.forcex) * dt
data.vel[i].y = data.vel[i].y + (dampy + self.forcey) * dt
+ data.angle[i] = data.angle[i] + data.angle_vel[i] * dt
+
-- move and bounce
data.pos[i].x = data.pos[i].x + data.vel[i].x * dt
if self:check_bounce(i) then
@@ -253,7 +270,7 @@ function Speck_Sys:draw()
lg.setColor(gradient:getPixel(sample_pos, 0.5))
lg.draw(
- tex, data.pos[i].x, data.pos[i].y, 0, scale, scale, w / 2, h / 2
+ tex, data.pos[i].x, data.pos[i].y, math.rad(data.angle[i]), scale, scale, w / 2, h / 2
)
lg.setColor(1, 1, 1, 1)
::next_speck_draw::