-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticles.lua
169 lines (156 loc) · 5.31 KB
/
particles.lua
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
PARTICLE_SNOW = 41
PARTICLE_HELP = 42
PARTICLE_RAIN = 43
local particles = {list = {}}
local path = "Sprites/Particles/"
local particlesetting = menu.settings[6]
function particles.spawnSmoke(x, y)
if particlesetting.value < 2 then return end
for i = 1,40 do
if not particles.list[i] then
particles.list[i] = {x = x, y = y}
particles.list[i].particle = love.graphics.newParticleSystem(GetImage(path.."smoke.png"), 10)
local particle = particles.list[i].particle
particle:setParticleLifetime(0.4, 0.7)
particle:setLinearAcceleration(-100, -100, 100, 100)
particle:setColors(1, 1, 1, 1, 1, 1, 1, 0)
particle:emit(10)
break
end
end
end
function particles.spawnShards(x, y, mult)
if particlesetting.value < 2 then return end
for i = 1,40 do
if not particles.list[i] then
particles.list[i] = {x = x, y = y}
particles.list[i].particle = love.graphics.newParticleSystem(GetImage(path.."shard.png"), 20*mult)
local particle = particles.list[i].particle
particle:setParticleLifetime(2*mult, 4*mult)
particle:setLinearAcceleration(-500*mult, -500*mult, 500*mult, 500*mult)
particle:setSpin(-15, 15)
particle:setColors(mult, mult, mult, mult, mult, 0, 0, 0)
particle:emit(20*mult)
break
end
end
end
function particles.spawnWarning(x, y, speed)
if particlesetting.value == 0 then return end
for i = 1,40 do
if not particles.list[i] then
particles.list[i] = {x = x, y = y}
particles.list[i].particle = love.graphics.newParticleSystem(GetImage(path.."warning.png"), 1)
local particle = particles.list[i].particle
particle:setParticleLifetime(speed or 1)
particle:setSizes(1, 1.5)
particle:setColors(1, 1, 1, 1, 1, 1, 1, 0)
particle:emit(1)
break
end
end
end
function particles.spawnStars(x, y)
if particlesetting.value < 2 then return end
for i = 1,40 do
if not particles.list[i] then
particles.list[i] = {x = x, y = y}
particles.list[i].particle = love.graphics.newParticleSystem(GetImage(path.."star.png"), 10)
local particle = particles.list[i].particle
particle:setParticleLifetime(2, 3)
particle:setLinearAcceleration(-100, -100, 100, 100)
particle:setSizes(1, 0)
particle:setColors(1, 1, 1, 0.7, 1, 1, 1, 0)
particle:emit(10)
break
end
end
end
function particles.spawnBridgeShards(x, y, amount, alpha)
if particlesetting.value < 2 then return end
for i = 1,40 do
if not particles.list[i] then
particles.list[i] = {x = x, y = y}
particles.list[i].particle = love.graphics.newParticleSystem(GetImage(path.."bridge.png"), amount)
local particle = particles.list[i].particle
local nextrow = tilemap[y + 1]
particle:setParticleLifetime(0.5, (nextrow and (nextrow[x] ~= TILE_EMPTY and 0.5)) or 1.3)
particle:setLinearAcceleration(0, 30, 0, 40)
particle:setSpin(-3, 3)
if tilesets[tilesetname].bridgeshardcolor then
tilesets[tilesetname].bridgeshardcolor[4] = alpha
particle:setColors(tilesets[tilesetname].bridgeshardcolor, {0, 0, 0, 0})
else
particle:setColors(1, 1, 1, alpha or 1, 0, 0, 0, 0)
end
particle:setEmissionArea("normal", 4, 4)
particle:setSizes(0.5)
particle:emit(amount)
break
end
end
end
function particles.spawnSnow()
if particlesetting.value < 3 then particles.reset(PARTICLE_SNOW) return end
if particles.list[PARTICLE_SNOW] then return end
particles.list[PARTICLE_SNOW] = {}
particles.list[PARTICLE_SNOW].particle = love.graphics.newParticleSystem(GetImage("Sprites/Particles/snow.png"), 100)
local particle = particles.list[PARTICLE_SNOW].particle
particle:setParticleLifetime(15, 25)
particle:setEmissionArea("normal", screenwidth+20, 0)
particle:setEmissionRate(5)
particle:setSizeVariation(1, 0.5)
particle:setLinearAcceleration(-30, 0, 30, 30)
particle:emit(1)
end
function particles.spawnHelp(x, y)
if particlesetting.value == 0 then return end
particles.list[PARTICLE_HELP] = {x = x, y = y}
particles.list[PARTICLE_HELP].particle = love.graphics.newParticleSystem(GetImage(path.."circle.png"), 1)
local particle = particles.list[PARTICLE_HELP].particle
particle:setParticleLifetime(1.5)
particle:setSizes(0.1, 5)
particle:setColors(1, 1, 1, 1, 1, 1, 1, 0)
particle:emit(1)
end
function particles.spawnRain()
if particlesetting.value < 3 then particles.reset(PARTICLE_RAIN) return end
if particles.list[PARTICLE_RAIN] then return end
particles.list[PARTICLE_RAIN] = {}
particles.list[PARTICLE_RAIN].particle = love.graphics.newParticleSystem(GetImage("Sprites/Particles/rain.png"), 500)
local particle = particles.list[PARTICLE_RAIN].particle
particle:setParticleLifetime(10)
particle:setEmissionArea("normal", screenwidth+20, 0)
particle:setEmissionRate(50)
particle:setSizes(1.7)
particle:setLinearAcceleration(0, 120, 0, 60)
particle:setColors(tilesets[tilesetname].rain)
particle:emit(1)
end
function particles.update(dt)
for k, v in pairs(particles.list) do
if v.particle then
v.particle:update(dt)
end
end
end
function particles.collectGarbage()
for k, v in pairs(particles.list) do
if v.particle:getCount() == 0 then
particles.list[k] = nil
end
end
end
function particles.reset(num)
if not num then
for key = 1,40 do
local particle = particles.list[key]
if particle then particle.particle:reset() end
end
else
local particle = particles.list[num]
if particle then particle.particle:reset() end
end
particles.collectGarbage()
end
return particles