Created
October 7, 2017 16:27
-
-
Save didicodethat/de6e8e6877855ecf5b3bf36ba1664f20 to your computer and use it in GitHub Desktop.
Fake 3D in love2d based on http://www.like100bears.com/writing/2d-3d-in-gamemaker-studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function(graphics, x, y, rx, ry, angle, size, distance) | |
local g = graphics | |
local i | |
local size = size or 1 | |
local half = size/2 | |
local distance = distance or 1 | |
for i = 0, 15 do | |
g.origin() | |
g.translate(x, y - (i * distance) ) | |
g.rotate(angle) | |
g.rectangle('fill', -half + rx, -half + ry, size, size) | |
g.origin() | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cube = require 'draw_cube' | |
local angle = 0 | |
local distance = 1 | |
local g = love.graphics | |
local w = g.getWidth() | |
local h = g.getHeight() | |
local x = w/2 | |
local y = h/2 | |
function love.draw() | |
drawCubeB() | |
drawCubeA() | |
end | |
function drawCubeA() | |
g.setColor(0x00, 0x00, 0xff) | |
cube(g, x, y, 30, 0, angle, 30, 1) | |
end | |
function drawCubeB() | |
g.setColor(0xff, 0xff, 0xff) | |
cube(g, x, y, 0, 0, angle, 30, 1 ) | |
end | |
function love.update() | |
-- love.timer.sleep(0.1) | |
angle = angle + 0.07 | |
-- distance = distance + 0.001 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment