-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzle.lua
More file actions
50 lines (43 loc) · 1.29 KB
/
Fizzle.lua
File metadata and controls
50 lines (43 loc) · 1.29 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
require 'Properties'
require 'Level'
require 'Camera'
require 'Common'
Fizzle = {list = {}}
local function tag(c,strength)
local tag = {}
-- TODO: what is fizzle supposed to do anyway?
tag.LifeTime = strength * Properties.FadeLengthFactor
tag.TimeLeft = tag.LifeTime
tag.Color = {r=c.r,g=c.g,b=c.b}
tag.Pos = {x=c.x,y=c.y}
table.insert(Fizzle.list,tag)
end
function Fizzle:tag(Fizzlething)
if not Fizzlething.collisions then
return
end
for _,c in ipairs(Fizzlething.collisions) do
c.r, c.g, c.b, c.a = Level:getPixel(c.x,c.y)
if c.a > Properties.CollisionAlpha and
Fizzlething.OperationStrength >= Materials:getHardness(c.r,c.g,c.b,c.a) then
tag(c,Fizzlething.OperationStrength)
end
end
end
function Fizzle:update(dt)
for index = #Fizzle.list,1,-1 do
if Fizzle.list[index].TimeLeft <= 0 then
table.remove(Fizzle.list,index)
else
Fizzle.list[index].TimeLeft = Fizzle.list[index].TimeLeft - dt
end
end
end
function Fizzle:draw()
for _,tag in ipairs(Fizzle.list) do
local cx, cy = Camera:worldToScreen(tag.Pos.x,tag.Pos.y)
local fade = tag.TimeLeft / tag.LifeTime
love.graphics.setColor(tag.Color.r,tag.Color.g,tag.Color.b,255*fade)
love.graphics.points(cx,cy)
end
end