-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
94 lines (75 loc) · 1.69 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require('util')
Class = require('class')
Object = require('object')
Hook = require('hook')
Timer = require('timer')
require('state')
Draw = require('draw')
require('faces')
Modes = {}
Modes.tgm = require('tgm/mode')
Modes.pento = require('pento/mode')
Modes.twist = require('twist/mode')
FPSTimer = require('fps')
MODE = Modes.twist
function love.load(args)
-- TODO accept replay file to verify
Draw.load()
startMode(MODE)
end
function startMode(m)
mode, game = m.new()
fpstimer = FPSTimer(m.fps or 60)
end
function love.update(dt)
if mode then
local frames = fpstimer:tick(dt)
for i = 1, frames do
game:update()
mode:update(game)
end
end
end
bindings = {}
function setbind(key, player, bind)
if player and bind then
bindings[key] = {player=player, name=bind}
else
bindings[key] = nil
end
end
setbind('q', 1, 'ccw')
setbind('e', 1, 'cw')
setbind('kp4', 1, 'left')
setbind('kp5', 1, 'down')
setbind('kp6', 1, 'right')
setbind('kp8', 1, 'up')
setbind('space', 1, 'hold')
function love.keypressed(key)
keyPressed(key, true)
end
function love.keyreleased(key)
keyPressed(key, false)
end
function keyPressed(key, value)
local bind = bindings[key]
if key == 'r' then
startMode(MODE)
end
if bind then
local player = game.players[bind.player]
if player then
player.input[bind.name] = value
end
end
end
function love.draw()
love.graphics.clear(127, 127, 127)
Draw.drawbg()
local scrw, scrh = love.graphics.getDimensions()
local h = scrh * .7
local w = h / 2
local x = scrw / 2 - w / 2
local y = scrh / 2 - h / 2
Draw.draw(game.wells[1], {x=x, y=y, w=w, h=h})
end