-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
main.lua
29 lines (25 loc) · 813 Bytes
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- written by groverbuger for g3d
-- september 2021
-- MIT license
local g3d = require "g3d"
local earth = g3d.newModel("assets/sphere.obj", "assets/earth.png", {4,0,0})
local moon = g3d.newModel("assets/sphere.obj", "assets/moon.png", {4,5,0}, nil, 0.5)
local background = g3d.newModel("assets/sphere.obj", "assets/starfield.png", nil, nil, 500)
local timer = 0
function love.update(dt)
timer = timer + dt
moon:setTranslation(math.cos(timer)*5 + 4, math.sin(timer)*5, 0)
moon:setRotation(0, 0, timer - math.pi/2)
g3d.camera.firstPersonMovement(dt)
if love.keyboard.isDown "escape" then
love.event.push "quit"
end
end
function love.draw()
earth:draw()
moon:draw()
background:draw()
end
function love.mousemoved(x,y, dx,dy)
g3d.camera.firstPersonLook(dx,dy)
end