summaryrefslogtreecommitdiffhomepage
path: root/not/Ray.lua
blob: e820dfb41e4c9aff62c399d657c7628668b365bb (plain)
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
--- That awesome effect that blinks when player dies!
Ray = require "not.Object":extends()

function Ray:new (source, world)
	self.source = source
	self.world = world
	self.delay = 1.2
end

function Ray:update (dt)
	self.delay = self.delay - dt
	if self.delay < 0 then
		return true -- delete
	end
	return false
end

-- TODO: Ray is work-in-progress.
-- TODO: Whole Ray is dated but `draw` require a lot attention due to layering in World. See `World@new`.
function Ray:draw ()
	love.graphics.setColor(255, 247, 228, 247)
	love.graphics.setLineStyle("rough")
	love.graphics.setLineWidth(self.delay*160)

	local x, y = self.source:getPosition()
	local m = self.world.map
	local dy = m.height

	if y > m.center.y then
		dy = -dy
	end

	local offset_x, offset_y = 0, 0

	-- love.graphics.rectangle("fill", 0, 0, 200, 200)

	love.graphics.line(-x+offset_x,-y+offset_y-dy*0.7,x+offset_x,y+dy*0.7+offset_y)
end

return Ray