kripken / BananaBread

BananaBread is a C++ 3D game engine that runs on the web using JavaScript+WebGL+HTML
1.38k stars 346 forks source link

Webrtc merge #38

Open modeswitch opened 11 years ago

modeswitch commented 11 years ago

Webrtc multiplayer support for BananaBread; Updated art assets and new levels from gk; Updated Makefile to avoid rebuilding packages all the time; Added manifest.txt and publish.sh to make packaging for upload to demo site easier

kripken commented 11 years ago

Great, thanks. Comments:

  1. Please add // XXX EMSCRIPTEN comments where you modified the engine cpp files
  2. We need the benchmarking stuff to work (benchmark.html). It fails on [12:44:17.278] TypeError: levelTitleContainer is null @ file:///home/alon/Dev/BananaBread/cube2/js/game-setup.js.
  3. We also need the shell benchmarking to work, js js/game-setup.js in the cube2 dir. I tried to fix that and got further with
diff --git a/cube2/js/game-setup.js b/cube2/js/game-setup.js
index 6d74f1a..de9a56c 100644
--- a/cube2/js/game-setup.js
+++ b/cube2/js/game-setup.js
@@ -1,9 +1,18 @@
 // Setup compiled code parameters and interaction with the web page

+var shell = typeof window == 'undefined';
+
+if (shell) {
+  load('game/headless.js');
+  load('game/headlessCanvas.js');
+  console = { info: print, log: print };
+  navigator = { userAgent: 'shell', platform: 'shell' };
+}
+
 var Query = {
   parse: function parse(queryString) {
     var result = {};
     var parts = queryString.split('&');
     parts.forEach(function(part) {
       var key = part.split('=')[0];
       if(!result.hasOwnProperty(key))
@@ -69,21 +78,14 @@ else
 var params = Query.parse(window.location.search.substring(1));
 console.info('params', params);

 var url = window.location.toString();
 url = clearQuery(url, 'serve');
 url = clearQuery(url, 'windowed');

-var shell = typeof window == 'undefined';
-
-if (shell) {
-  load('game/headless.js');
-  load('game/headlessCanvas.js');
-}
-
 function checkPageParam(param) {
   console.log('checkPageParam:', param);
   return Query.defined(params, param);
 }

 Date.realNow = Date.now;
 if (checkPageParam('deterministic')) {

but then it hangs. I wonder if we don't just want to disable networking or something like that.

klaussilveira commented 9 years ago

Sorry to bump this, but why wasn't it merged?

slacka commented 7 years ago

What was the hold up on this? Any chance @kripken or @modeswitch could fix the conflicts so it can be merged?

kripken commented 7 years ago

I don't remember the history here, but webrtc support in emscripten itself has stagnated, the tests have been disabled. We need more help in that area.

noahcoetsee commented 6 years ago

I believe we should switch to a more robust library like socket.io or engine.io with NodeJS for server side, like Inexor has done.

VinnyVicious commented 2 years ago

@modeswitch @kripken I know this is necroposting, but I was curious about BananaBread as an example of networking on Emscripten.

Are there more modern approaches? Or is this PR still a good piece of code to read and learn from?

roxanne-longyanran commented 2 years ago

这里是龙嫣然的邮箱,感谢您的来信。

kripken commented 2 years ago

@VinnyVicious I actually am not sure what the best example of that is atm. Might want to open a discussion on the emscripten repo perhaps.

modeswitch commented 2 years ago

@VinnyVicious This was intended to be a proof-of-concept. The underlying concepts should still work, even though the code is outdated. I won't guarantee that there isn't a more modern approach.