Tuesday, July 28, 2020

Non-VR (desktop 3D) game template for LOVR

main.lua:

camera = nil
cameraPosition = { x = 0.0, y = 0.0, z = 0.0 }
cameraTarget = { x = 0.0, y = 0.0, z = -1.0 }

function lovr.update()
    camera = lovr.math.newMat4():lookAt(
        vec3(cameraPosition.x, cameraPosition.y, cameraPosition.z), 
        vec3(cameraTarget.x, cameraTarget.y, cameraTarget.z))
    view = lovr.math.newMat4(camera):invert()
end

function lovr.mirror()
    lovr.graphics.clear()
    lovr.graphics.origin()
    lovr.graphics.transform(view)
    renderScene()
  end

function lovr.draw()
    -- Do nothing
end

renderScene = function()
    lovr.graphics.print('hello world', 0, 0, -3)
end

conf.lua:

function lovr.conf(t)
    t.identity = 'LOVR Non-VR Boilerplate'
    t.modules.headset = false
end

No comments:

Post a Comment