-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_hooks.lua
46 lines (37 loc) · 1.2 KB
/
game_hooks.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
local copas = require('copas')
local WebsocketConnection = require("neuro_game_sdk.websocket.websocket_connection")
local NeuroActionHandler = require("neuro_game_sdk.actions.neuro_action_handler")
local GameHooks = {}
ActionWindowsList = {}
local WebsocketConnectionInstance = nil
local NeuroActionHandlerInstance = nil
-- need to call this method in your 'game loop'/'update' method (e.g love.update)
function update(delta)
for _, ActionWindow in ipairs(ActionWindowsList)
do
if ActionWindow ~= nil then
ActionWindow:update(delta)
end
end
if WebsocketConnectionInstance ~= nil then
WebsocketConnectionInstance:update(delta)
end
end
-- need to call this method in your initialization code (e.g love.load)
function load()
WebsocketConnectionInstance = WebsocketConnection:new()
WebsocketConnectionInstance:load()
NeuroActionHandlerInstance = NeuroActionHandler.getInstance()
end
function quit()
copas.addthread(function()
if NeuroActionHandlerInstance ~= nil then
NeuroActionHandlerInstance:quit()
end
end)
copas.step()
end
GameHooks.update = update
GameHooks.load = load
GameHooks.quit = quit
return GameHooks