local util = include "util" local state = lib "stager" local global = state:new("Global") --[[ LOCALS ]]-- local lerpedHeadsetVelocity = { vx = 0, vy = 0, vz = 0 } function global:load() -- global.useHeadset = true global.camera = (class "Camera"):new({ x = 0, y = 0, z = 0, angle = 0, ax = 0, ay = 1, az = 0 }) global.cameraMode = "first" global.toastManager = (class "ToastManager"):new({ x = 0, y = 0, z = 0, angle = 0, ax = 0, ay = 0, az = 0 }) -- global.ambience = lovr.audio.newSource("sounds/ambience.ogg", "stream") -- global.ambience:setLooping(true) -- global.ambience:play() end function global:update(dt) local vx, vy, vz = lovr.headset.getVelocity("head") lerpedHeadsetVelocity.vx = util.lerp(lerpedHeadsetVelocity.vx, vx, 5 * dt) lerpedHeadsetVelocity.vy = util.lerp(lerpedHeadsetVelocity.vy, vy, 5 * dt) lerpedHeadsetVelocity.vz = util.lerp(lerpedHeadsetVelocity.vz, vz, 5 * dt) global.toastManager:update(dt) if global.robot then global.robot:update(dt) end end function global:draw() lovr.graphics.push() local x, y, z, angle, ax, ay, az = lovr.headset.getPose("head") lovr.graphics.transform(x, y, z, 1, 1, 1, angle, ax, ay, az) lovr.graphics.transform(0.12, 0.12, -0.5, 1, 1, 1, -0.15, 0, 1, 0) lovr.graphics.translate(-lerpedHeadsetVelocity.vx, -lerpedHeadsetVelocity.vy, -lerpedHeadsetVelocity.vz) global.toastManager:draw() lovr.graphics.pop() end function global:drawHud(f) lovr.graphics.push() local x, y, z, angle, ax, ay, az = lovr.headset.getPose("head") lovr.graphics.transform(x, y, z, 1, 1, 1, angle, ax, ay, az) lovr.graphics.transform(0, 0, -0.5, 1, 1, 1, 0, 0, 1, 0) lovr.graphics.translate(-lerpedHeadsetVelocity.vx, -lerpedHeadsetVelocity.vy, -lerpedHeadsetVelocity.vz) f() lovr.graphics.pop() end return global