summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-05-26 22:44:41 +0200
committerAki <nthirtyone@gmail.com>2017-05-26 22:44:41 +0200
commit5d744fdc20fefde18d4176e7e25273d27c217007 (patch)
treeffa08ec7ea1eb5f0ece0d3c3865344db4ca46890 /not
parentb14d4608dc921f882067c43c71fcf04db7b2f794 (diff)
downloadroflnauts-5d744fdc20fefde18d4176e7e25273d27c217007.zip
roflnauts-5d744fdc20fefde18d4176e7e25273d27c217007.tar.gz
roflnauts-5d744fdc20fefde18d4176e7e25273d27c217007.tar.bz2
Reviewed Ray which was way older than rest of stuff; moved to new oop module
Diffstat (limited to 'not')
-rw-r--r--not/Ray.lua40
1 files 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