-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
57 lines (47 loc) · 1.35 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
-- We don't know where she is from, or even what strain she is.
class = require("lib.30log.30log")
tiny = require("lib.tiny-ecs.tiny")
gamestate = require("lib.hump.gamestate")
-- start testing with time
local cron = require("lib.cron.cron")
local socket = require("socket")
local uuid = require("uuid")
-- Replace beholder with lib.hump.signal (!) ?
local observer = require("lib.beholder.beholder")
local tc = love.thread.newThread("src/TorchCraft.lua")
local Game = require("src.states.Game")
local updateFilter = tiny.rejectAny('isDrawSystem')
uuid.randomseed(socket.gettime()*10000)
local spawn_uuid = uuid()
-- global time in seconds
seconds = 0
local clock
function tick()
seconds = seconds + 1
end
print("Ophelia's LÖVE session " .. spawn_uuid)
function love.keypressed(k)
observer.trigger("keypress", k)
end
function love.keyreleased(k)
observer.trigger("keyrelease", k)
end
function love.load()
tc:start()
gamestate.registerEvents()
clock = cron.every(1, tick)
-- todo: dynamic map selection (!)
gamestate.switch(Game("maps/FightingSpirit.lua"))
end
function love.update(dt)
local time = love.thread.getChannel('time'):pop()
if time then
seconds = time
end
if world then
world:update(dt, updateFilter)
end
clock:update(dt)
end
-- quit
observer.observe("keypress", "escape", love.event.quit)