stuck with simple 3d
Posted: Sat Oct 22, 2011 5:55 pm
So i have this fairly simple code:
I want to add a basic 3d affect so that as i move the keys, the boxes move, but obviously at different speeds depending on their distance from the camera.
I'm guessing i need to add in a camera object and then work out the angles from there, but i'm not really sure how to do it.
Has anyone got a link to a decent tutorial on this kind of thing?
Code: Select all
local cubes = {}
for i = 1, 20 do
local c = {}
c.x = math.random(0,800)
c.y = math.random(0,600)
c.z = math.random(0,255)
tinsert(cubes, c)
end
function love.draw()
for i = 1, #cubes do
love.graphics.setColor(255,255,255,255-cubes[i].z)
love.graphics.rectangle("fill", cubes[i].x, cubes[i].y,10,10)
end
end
I'm guessing i need to add in a camera object and then work out the angles from there, but i'm not really sure how to do it.
Has anyone got a link to a decent tutorial on this kind of thing?