Skip to content

Commit

Permalink
add demo7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikaoto committed Apr 3, 2018
1 parent 47bbf12 commit 84a2733
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions demo7/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package.path = package.path .. ";../?.lua"
local deep = require "../deep"

local current_z = 1

-- Draws a rectangle at passed y coordinate
local draw_rectangle = function(y)
love.graphics.rectangle("fill", 200, y, 300, 10)
end

function love.draw()
deep.queue(2, draw_rectangle, 60)
deep.queue(3, draw_rectangle, 80)
deep.queue(4, draw_rectangle, 100)


-- Red square, which can move through z axis
deep.queue(current_z, function()
love.graphics.setColor(255, 0, 0) -- Set color to red
love.graphics.rectangle("fill", 300, 40, 80, 80)
love.graphics.setColor(255, 255, 255) -- Reset color
end)

-- Draw everything in the queue
deep.execute()
end

-- Increases/decreases player z on key press
function love.keypressed(key)
if key == "up" then
current_z = current_z + 1
elseif key == "down" then
current_z = current_z - 1
end
end

0 comments on commit 84a2733

Please sign in to comment.