forked from Sind/skyport-lovegraphics
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.lua
95 lines (83 loc) · 1.86 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
function love.load(args)
-- love.graphics.setMode( 0, 0 , false, false)
love.graphics.setMode(1024, 768, false, false)
-- love.graphics.setMode(love.graphics.getWidth(),love.graphics.getHeight(),false,false)
-- json = require "json"
json = require "dkjson"
class = require "class"
require "LUBE"
require "collectInfo"
require "waitingForConnect"
require "net"
require "render"
require "levelRender"
require "animations"
gamemodes = {collectInfo,waitingForConnect,levelRender}
--[[
if #args == 5 then
ip = args[2]
port = tonumber(args[3])
mode = 2
else
mode = 1
end
]]--
ip = "localhost"
port = 54331
mode = 2
gamestateset = false
love.filesystem.setIdentity("Skyport - samplegraphics")
quit = false
init = true
end
function love.draw()
if gamemodes[mode].draw then
gamemodes[mode].draw()
end
end
function love.update(dt)
if conn then
conn:update(dt)
end
if gamemodes[mode].update then
gamemodes[mode].update(dt)
end
collectgarbage('collect')
end
function love.keypressed(key,unicode)
if key == "escape" then
love.event.push("quit") -- actually causes the app to quit
end
if gamemodes[mode].keypressed then
gamemodes[mode].keypressed(key,unicode)
end
end
function love.keyreleased(key,unicode)
if gamemodes[mode].keyreleased then
gamemodes[mode].keyreleased(key,unicode)
end
end
function split(str, pat)
str = str or "0,0"
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
function tablePrint(table)
for k,v in pairs(table) do
print(k.."\t"..v)
end
end