-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
48 lines (36 loc) · 1018 Bytes
/
main.lua
File metadata and controls
48 lines (36 loc) · 1018 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
_G.math.turn = 2 * math.pi
_G.math.phi = (1 + math.sqrt(5)) / 2
local nata = require 'nata'
local tags = {}
local pool = nata.new {
groups = {
vehicle = {filter = {'id', 'name', 'vehicle_type'}},
},
systems = {
require'Vehicle',
require'Terrain',
require'Skybox',
},
data = {
world = lovr.physics.newWorld(0, -9.81, 0, false, tags)
}
}
pool.data.world:setLinearDamping(0.01)
pool.data.world:setAngularDamping(0.05)
local perspective = mat4():perspective(0.1, 1000, 70, lovr.graphics.getWidth() / lovr.graphics.getHeight())
lovr.graphics.setProjection(1, perspective)
function lovr.update(dt)
pool:emit('update', dt)
pool:remove(function(entity) return entity.expired end)
pool.data.world:update(1/72)
pool:flush()
end
function lovr.draw()
lovr.graphics.transform(mat4(vehicle.collider:getPose()):invert())
lovr.graphics.setColor(1, 1, 1)
pool:emit('draw')
lovr.graphics.setColor(0, 1, 0)
end
function lovr.keypressed(...)
pool:emit('keypressed', ...)
end