-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.lua
71 lines (55 loc) · 1.67 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
love.graphics.setBackgroundColor(225, 225, 225)
love.graphics.setDefaultFilter("nearest", "nearest")
-- Load Lovox
local Lovox = require "lovox"
local ModelData = Lovox.modelData
local Model = Lovox.model
local AnimModel = Lovox.animModel
local Camera = Lovox.camera
-- Load a boat
local BoatData = ModelData("boat")
local Boat = Model(BoatData)
-- Load a model from a function
local func = function()
love.graphics.setColor(255, 30, 30)
love.graphics.circle("fill", 25, 25, 25)
end
local CircleData = ModelData(func, 50, 50)
local Circle = Model(CircleData)
local CircleRot = 0
-- Load cubes as a animation
local b1, b2, b3 = ModelData("cube/1"), ModelData("cube/2"), ModelData("cube/3")
local Cube = AnimModel({b1, b2, b3}, 1)
Cube:setLooping(true)
Cube:play()
-- Load a model from a .vox
-- !! Slow !!
local BarrierData = ModelData('barrier_bend.vox') -- newFromVox is required here.
local Barrier = Model(BarrierData)
function love.update(dt)
-- Rotate our circle
CircleRot = CircleRot + dt
Cube:update(dt)
end
function love.draw()
-- Draw our models
Boat:draw (-200, 0, 0, nil, 4, 4)
Circle:draw ( 200, 0, 0, CircleRot, 4, 4)
Cube:draw ( 0, -200, 0, nil, 4, 4)
Barrier:draw( 0, 200, 0, nil, 4, 4)
-- Render all our models
Camera:render()
end
function love.mousemoved(x, y, dx, dy)
-- Rotate the camera by click-dragging
if love.mouse.isDown(1) then
Camera:rotate(-(dx / 100))
end
end
function love.resize(w, h)
Camera:resize(w, h)
end
-- Replace the circle model with the dropped model
function love.filedropped(file)
Circle = Model(ModelData.newFromVox(file))
end