summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2024-12-22 22:17:44 -0600
committerAlexander M Pickering <alex@cogarr.net>2024-12-22 22:17:44 -0600
commit726876d42270f8974fd495be91127ea7585472ff (patch)
treecfd6f6c32e1d6e97144e326092ae091a3e6f2795
parent8fd93fad84e043def785e594b4745e56c88c5d48 (diff)
downloadggj25-726876d42270f8974fd495be91127ea7585472ff.tar.gz
ggj25-726876d42270f8974fd495be91127ea7585472ff.tar.bz2
ggj25-726876d42270f8974fd495be91127ea7585472ff.zip
Get things working
-rw-r--r--AUTHORS1
-rw-r--r--Makefile1
-rw-r--r--data_src/ui/ui.pngbin0 -> 13101 bytes
-rw-r--r--src/js_bridge.js45
-rw-r--r--src/main.lua5
5 files changed, 31 insertions, 21 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..8904579
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+opengameart.org user Buch
diff --git a/Makefile b/Makefile
index 27b26ca..9bb3753 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,7 @@ $(test_moon) : spec/%.lua : src/%.moon
$(MOONC) -p $< > $@
$(built_js) : data/%.lua : src/%.js
+ npx jshint $<
echo "return [=====[" > $@
cat $< >> $@
echo "]=====]" >> $@
diff --git a/data_src/ui/ui.png b/data_src/ui/ui.png
new file mode 100644
index 0000000..6b3eafc
--- /dev/null
+++ b/data_src/ui/ui.png
Binary files differ
diff --git a/src/js_bridge.js b/src/js_bridge.js
index a9c8873..46065cb 100644
--- a/src/js_bridge.js
+++ b/src/js_bridge.js
@@ -1,24 +1,31 @@
var s = document.createElement('script');
-var PEER = {};
s.setAttribute('src','https://unpkg.com/peerjs@1.5.2/dist/peerjs.min.js');
document.body.appendChild(s);
function genRanHex(size) {
- return Array.apply(null,Array(size)).map(() => Math.floor(Math.random() * 16).toString(16)).join('');
+ return Array.apply(null,Array(size)).map(function(){
+ Math.floor(Math.random() * 16).toString(16);
+ }).join('');
+
}
-PEER.event_queue = {};
-PEER.peers = {};
-PEER.message_queue = {};
-PEER.create = function(name, options) {
- var peer = new Peer(name, options);
- PEER.peers[name] = peer;
-};
-/*
-PEER["on"] = function(name, e, message) {
- PEER.peers[name].on(e, function(data) {
- PEER.message_queue.push({"message":message, "data":data})
- }
-}
-PEER["connect"] = function(name, id, options) {
- PEER.peers[name].connect(id, options)
-}
-*/
+window.PEER = {
+ event_queue: {},
+ peers: {},
+ message_queue: {},
+ create: function(name, options) {
+ var peer = new Peer(name, options);
+ PEER.peers[name] = peer;
+ },
+ on: function(name, e, message) {
+ PEER.peers[name].on(e, function(data) {
+ PEER.message_queue.push({"message":message, "data":{
+ "call": "on",
+ "peer": name,
+ "e": e,
+ "data": data
+ }});
+ });
+ },
+ connect: function(name, id, options) {
+ PEER.peers[name].connect(id, options);
+ },
+};
diff --git a/src/main.lua b/src/main.lua
index 176cddc..8c8461a 100644
--- a/src/main.lua
+++ b/src/main.lua
@@ -4,11 +4,12 @@ print("Hello, world!")
am.eval_js("console.log('Hello, js!')")
local win = am.window{
- title = "Hi",
+ title = "ggj25",
width = 1280,
height = 720,
clear_color = vec4(0.8, 0.8, 0.3, 1)
}
print("about to pcall")
-local a,b = pcall(am.eval_js, require("js_bridge"))
+am.eval_js(require("js_bridge"))
+--local a,b = pcall(am.eval_js, require("js_bridge"))
print("done with pcall", a,b)