-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.lua
More file actions
68 lines (52 loc) · 1.98 KB
/
Copy pathpreview.lua
File metadata and controls
68 lines (52 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local preview = {}
-- whether to fade out the default background
preview.hide_background = false
function preview:init(mod, button, menu)
-- code here gets called when the mods are loaded
self.particles = {}
self.particle_timer = 0
button:setColor(0.7, 1, 1)
button:setFavoritedColor(1, 0.7, 1)
self.menu = menu
end
function preview:update()
-- code here gets called every frame, before any draws
-- to only update while the mod is selected, check self.selected (or self.fade)
local to_remove = {}
for _,particle in ipairs(self.particles) do
particle.radius = particle.radius
particle.radius = particle.radius - (DT * 4)
particle.y = particle.y - particle.speed * (DTMULT * 2)
if particle.radius <= 0 then
table.insert(to_remove, particle)
end
end
for _,particle in ipairs(to_remove) do
Utils.removeFromTable(self.particles, particle)
end
self.particle_timer = self.particle_timer + DT
if self.particle_timer >= 0.25 then
self.particle_timer = 0
local radius = Utils.random() * 48 + 16
table.insert(self.particles, {radius = radius, x = Utils.random() * SCREEN_WIDTH, y = SCREEN_HEIGHT + radius, max_radius = radius, speed = Utils.random() * 0.5 + 0.5})
end
end
function preview:draw()
-- code here gets drawn to the background every frame!!
-- make sure to check self.fade or self.selected here
if self.fade > 0 then
love.graphics.setBlendMode("add")
for _,particle in ipairs(self.particles) do
local alpha = (particle.radius / particle.max_radius) * self.fade
love.graphics.setColor(1, 1, 0.5, alpha)
love.graphics.circle("fill", particle.x, particle.y, particle.radius)
end
love.graphics.setBlendMode("alpha")
end
end
function preview:drawOverlay()
-- code here gets drawn above the menu every frame
-- so u can make cool effects
-- if u want
end
return preview