aboutsummaryrefslogtreecommitdiff
path: root/bin/main.lua
blob: bd2c011c1909d26c4120e3e602249b9b5e39169a (plain)
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
local loadAssets = [[
local thread = jin.thread.getThread()
local path = thread:demand(1)
local img = jin.graphics.Image(path)
thread:send(2, img)
while(true) do
	if(thread:receive(255)) then 
		break; -- quit thread
	end 
end
]] 

local img = nil 
local loader = nil

jin.core.onLoad = function() 
	loader = jin.thread.Thread("load assets", loadAssets) 
	loader:start()
	loader:send(1, "./icon.png")
	--img = jin.graphics.Image("./icon.png")
end 

jin.core.onEvent = function(e)
	if e.type == "quit" then 
		jin.core.stop()
	end 
end

jin.core.onUpdate = function(dt)
	if loader:receive(2) and img == nil then 
		img = loader:fetch(2)
		loader:send(255, 1)
		loader:remove(2)
	end 
end 

jin.core.onDraw = function()
	if img ~= nil then 
		jin.graphics.draw(img, 20, 20)
	end
end