summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-06-29 18:08:46 +0200
committerAki <nthirtyone@gmail.com>2016-06-29 18:08:46 +0200
commitea5d83d8897e5e1fb6fb8b1f0dba89dfd4c56991 (patch)
tree745df862cee6e2ad4f38f4744ffe3792d5da2f65
parent5ef009920f2f180e21c2b0d910af438a180512b0 (diff)
downloadroflnauts-ea5d83d8897e5e1fb6fb8b1f0dba89dfd4c56991.zip
roflnauts-ea5d83d8897e5e1fb6fb8b1f0dba89dfd4c56991.tar.gz
roflnauts-ea5d83d8897e5e1fb6fb8b1f0dba89dfd4c56991.tar.bz2
Pixelated Rayyysss!
-rw-r--r--ray.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/ray.lua b/ray.lua
index 433ef1c..09d590c 100644
--- a/ray.lua
+++ b/ray.lua
@@ -6,6 +6,7 @@
Ray = {
naut = nil,
world = nil,
+ canvas = nil,
delay = 0.3
}
function Ray:new(naut, world)
@@ -16,6 +17,10 @@ function Ray:new(naut, world)
-- Init
o.naut = naut
o.world = world
+ -- Cavas, this is temporary, I believe.
+ local scale = o.world.camera.scale
+ local w, h = love.graphics.getWidth(), love.graphics.getHeight()
+ o.canvas = love.graphics.newCanvas(w/scale, h/scale)
return o
end
function Ray:update(dt)
@@ -26,14 +31,21 @@ function Ray:update(dt)
return false
end
function Ray:draw(offset_x, offset_y, scale)
+ love.graphics.setCanvas(self.canvas)
+ love.graphics.clear()
love.graphics.setLineStyle("rough")
- love.graphics.setLineWidth(self.delay*160*scale)
+ 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)*scale,(-y+offset_y-dy*0.7)*scale,(x+offset_x)*scale,(y+dy*0.7+offset_y)*scale)
+ 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)
end