-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
202 lines (181 loc) · 3.57 KB
/
Copy pathmain.lua
File metadata and controls
202 lines (181 loc) · 3.57 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
-- BLAST FLOCK source files
-- by TRASEVOL_DOG (https://trasevol.dog/)
if CASTLE_PREFETCH then
CASTLE_PREFETCH({
'client.lua',
'server.lua',
'audio.lua',
'drawing.lua',
'game.lua',
'game_elements.lua',
'game_ui.lua',
'game_board.lua',
'gameover.lua',
'lobby.lua',
'input.lua',
'shader.lua',
'maths.lua',
'sprite.lua',
'object.lua',
'ttable.lua',
'task.lua',
'nnetwork.lua',
'menu.lua',
'fx.lua',
'assets/Marksman.ttf',
'assets/EffortsPro.ttf',
'assets/sheet.png',
'palswap.shader'
})
end
require("game")
require("drawing")
require("input")
require("sprite")
require("shader")
require("maths")
require("audio")
require("nnetwork")
ROLE = nil
USE_CASTLE_CONFIG = (castle ~= nil)
require("server")
require("client")
if not castle then
castle_log = {}
castle_print = function(str)
add(castle_log, str)
end
end
if not USE_CASTLE_CONFIG then
function love.load(args)
if castle then
init_graphics(400,300)
init_audio()
init_shader_mgr()
init_input_mgr()
font("big")
pal()
color(23)
end
if args[1] == "server" then
start_server()
elseif args[1] == "client" then
start_client()
end
end
function love.draw()
if ROLE then
-- font("big")
-- color(23)
love.graphics.print("Running server.", 32, 32)
if not castle then
local y = 48
local n = #castle_log
while n > 0 do
love.graphics.print(castle_log[n], 48, y)
n = n-1
y = y+16
end
end
else
love.graphics.print("Press 1 to launch local server.", 32, 32)
love.graphics.print("Press 2 to launch local client.", 32, 64)
end
end
function love.keyreleased(key)
if key == '1' then
love.keyreleased = nil
start_server()
elseif key == '2' then
love.keyreleased = nil
start_client()
end
end
end
--local client_init = false
--function love.load()
-- castle_print("Starting client init...")
--
-- init_graphics(2,2)
-- init_audio()
-- init_shader_mgr()
-- init_input_mgr()
-- font("small")
-- pal()
--
-- predraw()
-- _init()
-- afterdraw()
--
-- love.keyboard.setKeyRepeat(true)
-- love.keyboard.setTextInput(false)
--
-- client_init = true
-- castle_print("Client init done!")
--end
--local client_load_sav = love.load
--
--delta_time = 0
--dt30f = 0
--function love.update(dt)
-- delta_time = dt
-- dt30f = dt*30
--
-- _update(dt)
-- update_input_mgr()
--end
--
--function love.draw()
-- if not client_init then
-- castle_print("no init.")
-- return
-- end
--
-- predraw()
-- _draw()
-- afterdraw()
--end
--
--
--function love.resize(w,h)
-- render_canvas=love.graphics.newCanvas(w,h)
-- render_canvas:setFilter("nearest","nearest")
-- local scx,scy=screen_scale()
--
-- graphics.wind_w=w
-- graphics.wind_h=h
-- graphics.scrn_w=flr(w/scy)
-- graphics.scrn_h=flr(h/scx)
--end
--
--function love.textinput(text)
-- menu_textinput(text)
--end
--
--function love.keypressed(key)
-- input_keypressed(key)
--end
--
--function love.keyreleased(key)
-- input_keyreleased(key)
--end
--
--function love.mousepressed(x,y,k,istouch)
-- input_mousepressed(x,y,k,istouch)
--end
--
--function love.mousereleased(x,y,k,istouch)
-- input_mousereleased(x,y,k,istouch)
--end
function step()
if love.timer then
love.timer.step()
dt = love.timer.getDelta()
if dt < 1/30 then
love.timer.sleep(1/30 - dt)
end
dt=max(dt,1/30)
end
end
function eventpump() -- here to avoid things bugging out
end