From 5d744fdc20fefde18d4176e7e25273d27c217007 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 26 May 2017 22:44:41 +0200 Subject: Reviewed Ray which was way older than rest of stuff; moved to new oop module --- not/Ray.lua | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/not/Ray.lua b/not/Ray.lua index bbe11c1..8edf51f 100644 --- a/not/Ray.lua +++ b/not/Ray.lua @@ -1,36 +1,32 @@ --- `Ray` +require "not.Object" + +--- `Ray` -- That awesome effect that blinks when player dies! +Ray = Object:extends() --- WHOLE CODE HAS FLAG OF "need a cleanup" +Ray.naut =--[[not.Hero]]nil +Ray.world =--[[not.World]]nil +Ray.canvas =--[[love.graphics.newCanvas]]nil +Ray.delay = 0.3 -Ray = { - naut = nil, - world = nil, - canvas = nil, - delay = 0.3 -} -function Ray:new(naut, world) - -- Meta - local o = {} - setmetatable(o, self) - self.__index = self - -- Init - o.naut = naut - o.world = world +function Ray:new (naut, world) + self.naut = naut + self.world = world -- Cavas, this is temporary, I believe. - local scale = o.world.camera.scale + local scale = self.world.camera.scale local w, h = love.graphics.getWidth(), love.graphics.getHeight() - o.canvas = love.graphics.newCanvas(w/scale, h/scale) - return o + self.canvas = love.graphics.newCanvas(w/scale, h/scale) end -function Ray:update(dt) + +function Ray:update (dt) self.delay = self.delay - dt if self.delay < 0 then return true -- delete end return false end -function Ray:draw(offset_x, offset_y, scale) + +function Ray:draw (offset_x, offset_y, scale) love.graphics.setCanvas(self.canvas) love.graphics.clear() love.graphics.setColor(255, 247, 228, 247) @@ -50,3 +46,5 @@ function Ray:draw(offset_x, offset_y, scale) -- draw on screen love.graphics.draw(self.canvas, 0, 0, 0, scale, scale) end + +return Ray -- cgit v1.1