-
Notifications
You must be signed in to change notification settings - Fork 25
/
main.lua
114 lines (104 loc) · 2.52 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
socket = require("socket")
json = require("dkjson")
async = require("async")
require("stridx")
require("util")
require("class")
require("queue")
loveframes = require("loveframes")
require("network")
require("engine")
require("cards")
require("buff")
require("skills")
require("spells")
require("characters")
require("input")
require("graphics")
require("mainloop")
require("validate")
require("giftable")
require("filters")
require("xmutable")
require("animation")
require("sounds")
require("options")
--require("imagedata-ffi")
local N_FRAMES = 0
local min = math.min
local mainloop
function love.load(arg)
arg = arg or {}
GLOBAL_EMAIL, GLOBAL_PASSWORD = arg[2], arg[3]
leftover_time = 1/120
async.load()
async.ensure.exactly(4)
if GLOBAL_EMAIL == "--server" then
require("server")
end
math.randomseed(os.time())
for i=1,4 do math.random() end
graphics_init() -- load images and set up stuff
mainloop = coroutine.create(fmainloop)
local t,s={},{}
for k,v in pairs(skill_func) do
if (not rawget(skill_id_to_type, k)) then
t[#t+1] = k
end
if not skill_text[k] then
s[#s+1] = k
end
end
table.sort(t)
for _,k in ipairs(t) do
--print(tostring(k).." lacks a type")
end
for _,k in ipairs(s) do
--print(tostring(k).." lacks a description")
end
if #t > 0 then
error("some skills lack types")
end
if #s > 0 then
-- error("some skills lack descriptions")
end
end
function love.update(dt)
--print("FRAME BEGIN")
async.update()
leftover_time = leftover_time + dt
for i=1,3 do
if leftover_time >= 1/60 then
local status, err = coroutine.resume(mainloop)
if not status then
error(err..'\n'..debug.traceback(mainloop))
end
if game then
game:update()
end
do_messages()
loveframes.update((1/60)/3)
loveframes.update((1/60)/3)
loveframes.update((1/60)/3)
leftover_time = leftover_time - 1/60
end
end
end
local hover_states = arr_to_set({"playing", "decks", "craft", "cafe", "xmute"})
function love.draw()
love.graphics.setColor(255,255,255)
draw_background()
if game then game:draw() end
local state = loveframes.GetState()
if hover_states[state] then
draw_hover_card(frames[state].card_text)
end
if state == "select_faction" then
love.graphics.draw(load_asset("select_faction.png"), 153, 58)
end
--love.graphics.print("FPS: "..love.timer.getFPS(),315,15)
loveframes.draw()
if DISPLAY_FRAMERATE then
love.graphics.print(tostring(love.timer.getFPS()), 0, 0)
end
end