diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/client/config.lua | 8 | ||||
-rw-r--r-- | bin/client/main.lua | 43 | ||||
-rw-r--r-- | bin/jin.exe | bin | 651776 -> 1680384 bytes | |||
-rw-r--r-- | bin/main.lua | 40 |
4 files changed, 39 insertions, 52 deletions
diff --git a/bin/client/config.lua b/bin/client/config.lua deleted file mode 100644 index 3e696b8..0000000 --- a/bin/client/config.lua +++ /dev/null @@ -1,8 +0,0 @@ -return -{ - width = 512, - height = 400, - fullscreen = false, - resizable = true, - title = "Jin Modules" -} diff --git a/bin/client/main.lua b/bin/client/main.lua deleted file mode 100644 index 5a036e8..0000000 --- a/bin/client/main.lua +++ /dev/null @@ -1,43 +0,0 @@ -io.stdout:setvbuf("no") -local thread = nil -local socket = nil -local asynReceive = [[ -io.stdout:setvbuf("no") -local thread = jin.thread.getThread() -local socket = thread:demand(1) -local buf = nil -while true do - buf = socket:receive() - thread:send(2, buf) -end -]] -jin.core.onLoad = function() - jin.net.init() - socket = jin.net.Socket("TCP", "127.0.0.1", 8708) - - thread = jin.thread.Thread("asynReceive", asynReceive) - thread:start() - thread:send(1, socket) -end - -jin.core.onEvent = function(e) - if e.type == "quit" then - jin.core.stop() elseif e.type == "keydown" then - if e.key == "Escape" then - jin.core.stop() - end - end -end -local x = 0 -local y = 0 -jin.core.onUpdate = function(dt) - if thread:receive(2) then - local buf = thread:fetch(2) - x, xl = buf:grabFloat(0) - y, yl = buf:grabFloat(xl) - end -end - -jin.core.onDraw = function() - jin.graphics.circle("fill", x, y, 12) -end diff --git a/bin/jin.exe b/bin/jin.exe Binary files differindex 839622b..43703b7 100644 --- a/bin/jin.exe +++ b/bin/jin.exe diff --git a/bin/main.lua b/bin/main.lua index b7f7124..bd2c011 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -1,3 +1,41 @@ -require "client.main" +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 |