-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProbe.lua
More file actions
53 lines (46 loc) · 1.33 KB
/
Probe.lua
File metadata and controls
53 lines (46 loc) · 1.33 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
require 'Properties'
require 'Materials'
require 'Camera'
require 'Common'
Probe = {list = {}}
local function tag(c,strength)
local tag = {}
tag.Material = Materials:GetMaterial(c.r,
c.g,
c.b,
c.a)
if not tag.Material then
return
end
tag.LifeTime = strength
tag.TimeLeft = tag.LifeTime
tag.Pos = {x=c.x,y=c.y}
table.insert(Probe.list,tag)
end
function Probe:tag(probething)
if not probething.collisions then
return
end
for _,c in ipairs(probething.collisions) do
tag(c,probething.OperationStrength)
end
end
function Probe:update(dt)
for index = #Probe.list,1,-1 do
if Probe.list[index].TimeLeft <= 0 then
table.remove(Probe.list,index)
else
Probe.list[index].TimeLeft = Probe.list[index].TimeLeft - dt
end
end
end
function Probe:draw()
for _,tag in ipairs(Probe.list) do
local cx, cy = Camera:worldToScreen(tag.Pos.x,tag.Pos.y)
local fade = tag.TimeLeft / tag.LifeTime
love.graphics.setColor(255,255,255,155*fade)
love.graphics.print(tag.Material.name,cx+Properties.DropShadow,cy+Properties.DropShadow)
love.graphics.setColor(0,0,0,255*fade)
love.graphics.print(tag.Material.name,cx,cy)
end
end