diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-21 21:05:37 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-21 21:05:37 +0200 |
commit | e9a450d65d4fb564691cdf651ef5771dd88303ae (patch) | |
tree | f49d29582dd6877f3b3c807c3f7d9d92d368f798 /not/Ray.lua | |
parent | eb8302723cd85adca0fbaf505cfb315f1db0299a (diff) | |
parent | b97985def64b8bd8f93a7b391b12333595432e52 (diff) | |
download | roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.zip roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.gz roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.bz2 |
Merge branch 'maps'
Diffstat (limited to 'not/Ray.lua')
-rw-r--r-- | not/Ray.lua | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/not/Ray.lua b/not/Ray.lua index 16a9bee..4ae640a 100644 --- a/not/Ray.lua +++ b/not/Ray.lua @@ -1,21 +1,10 @@ -require "not.Object" +--- That awesome effect that blinks when player dies! +Ray = require "not.Object":extends() ---- `Ray` --- That awesome effect that blinks when player dies! -Ray = Object:extends() - -Ray.naut =--[[not.Hero]]nil -Ray.world =--[[not.World]]nil -Ray.canvas =--[[love.graphics.newCanvas]]nil -Ray.delay = 0.3 - -function Ray:new (naut, world) - self.naut = naut +function Ray:new (source, world) + self.source = source self.world = world - -- Cavas, this is temporary, I believe. - local scale = getScale() - local w, h = love.graphics.getWidth(), love.graphics.getHeight() - self.canvas = love.graphics.newCanvas(w/scale, h/scale) + self.delay = 0.3 end function Ray:update (dt) @@ -26,25 +15,16 @@ function Ray:update (dt) return false end -function Ray:draw (offset_x, offset_y, scale) - love.graphics.setCanvas(self.canvas) - love.graphics.clear() +-- TODO: Ray should use Camera boundaries just-in-case. +-- TODO: Ray uses magic numbers. +function Ray:draw () love.graphics.setColor(255, 247, 228, 247) love.graphics.setLineStyle("rough") love.graphics.setLineWidth(self.delay*160) - local x, y = self.naut:getPosition() - local m = self.world.map - local dy = m.height - if y > m.center_y then - dy = -dy - end - love.graphics.line(-x+offset_x,-y+offset_y-dy*0.7,x+offset_x,y+dy*0.7+offset_y) - -- reset - love.graphics.setCanvas() - love.graphics.setLineWidth(1) - love.graphics.setColor(255,255,255,255) - -- draw on screen - love.graphics.draw(self.canvas, 0, 0, 0, scale, scale) + + local x, y = self.source:getPosition() + + love.graphics.line(x, y, -x, -y) end return Ray |