shell.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <!doctype html>
  2. <html lang="EN-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>raylib web game</title>
  7. <meta name="title" content="raylib web game">
  8. <meta name="description" content="New raylib web videogame, developed using raylib videogames library">
  9. <meta name="keywords" content="raylib, programming, examples, html5, C, C++, library, learn, games, videogames">
  10. <meta name="viewport" content="width=device-width">
  11. <!-- Open Graph metatags for sharing -->
  12. <meta property="og:type" content="website" />
  13. <meta property="og:title" content="raylib web game">
  14. <meta property="og:image:type" content="image/png">
  15. <meta property="og:image" content="https://www.raylib.com/common/raylib_logo.png">
  16. <meta property="og:image:alt" content="New raylib web videogame, developed using raylib videogames library" />
  17. <meta property="og:site_name" content="raylib - example">
  18. <meta property="og:url" content="https://www.raylib.com/games.html">
  19. <meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">
  20. <!-- Twitter metatags for sharing -->
  21. <meta name="twitter:card" content="summary_large_image">
  22. <meta name="twitter:site" content="@raysan5">
  23. <meta name="twitter:title" content="raylib web game">
  24. <meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
  25. <meta name="twitter:image:alt" content="New raylib web videogame, developed using raylib videogames library">
  26. <meta name="twitter:url" content="https://www.raylib.com/games.html">
  27. <meta name="twitter:description" content="New raylib web videogame, developed using raylib videogames library">
  28. <!-- Favicon -->
  29. <link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
  30. <style>
  31. body { font-family: arial; margin: 0; padding: unset; }
  32. #header {
  33. width: 100%;
  34. height: 80px;
  35. background-color: #888888;
  36. }
  37. /* NOTE: raylib logo is embedded in the page as base64 png image */
  38. #logo {
  39. width:64px;
  40. height:64px;
  41. float:left;
  42. position:relative;
  43. margin:10px;
  44. background-image:url('data:image/png;base64,\
  45. iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADs\
  46. MAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAA7JJREFUaEPtk0FyWzEMQ+37X7fZhxX4\
  47. YY3AD1OKF1nkzTRlSBCCLeVBnvl/AUdaELOunPno1kts1kixdtEZKVs+xIxebBkZsVknn/L5nFGDLR8T4zVC9fX19S/+tTFijr\
  48. YK4jUjbPUtqBHpnEE6PkZD7jQZV8n5Recw1XQKciZuPaEtR6UjNs5ENVGMsBVqpPtER0ZMOhpyp8m4YL4OjD9yxsyZxnQycfMJ\
  49. ETNSzsRE1+dihK3YMiJmpHTW3xpmXPC6BXlCHfqnBlsjY5hxf/6EVEOM2BTEi0fYCX4ONSI6Kq3Blg/prIOMq2CsRur4KQ0x64\
  50. SdjOufEDEdHZGOhmz5RDHCVqhRuQ86YsVskbc+GXchLiHnFyYH+UigQDVGnImbT8hwFkgLg2qiM8JO6Ylx1FNLa3DmYwqCTsZd\
  51. 4BPqGJG7MwKzpeiWKTKxXkLMVE3MSOmsdwxLH6Rd/wCCLSNDx6djeKfJuArGeoYamRHpaEjnCBYZVy8hZqo2GI36qPjsiOiMsB\
  52. XGcev4Mx9TLGTchbgEjN/uz6jGrBvDjg+LTNx8Qp2CbG2xMKgmOiPslJ4Yxx+eSnSkzlosZNwFPiHl7FRTkLNRJm4+IeVM0ymI\
  53. H42wE/wcKalQI4MRl4EW3p6VcRWMua8F6WjIlqZDxvVPiHQ6CjVbYkV9ohhhp/Rk1wiYgpyJ78i4CsZbjkb8Qx+ihvzu3RPaKo\
  54. gZkY6GlEeMsKdPSOFIC8VoOusg44L5c+T8ouOoGhWbdWJ8tMi4egkxo4hoh2yNTGf3iIyr5Lyic4bRENXo+lvDjAt4C1Hk/OKt\
  55. UaAj0+n4dMSZ2D+hrYJsaYh2SClG2jV9kJKKzhlGQ1SsW299Mq6C8dYZHTExo8fzieI5ivipYnYy7nwJqGKmOYyRwfiUBXITfh\
  56. 5qSHRGWEkfqJqURgvsdHyWYv7Ko8DnYYegk3EB00cxprdrJRzFd7YQzawu8L1GMTYS/KpPaAFTkIn1EmJmspJSs5xBzSyGhlkB\
  57. mlxfNFiP5mw4wlbMh4F5Ddxp5jNINBdCEz9zPOC1zD7Q0HBdmXndwv0TMtydEdzlWJT4VZ8Qt9Qn4/onxMIwa5ZYGJU5yufBiC\
  58. jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaBBfOTCGHM2aEbZi1+gO\
  59. 1XTWVXMnzrhAn5DSOZVsiQlHnSITKzGj6DeTcZWc/3oy7h9//PF4PL4BlvsWrb6RE+oAAAAASUVORK5CYII=');
  60. }
  61. .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
  62. div.emscripten { text-align: center; }
  63. div.emscripten_border { border: 1px solid black; }
  64. /* NOTE: Canvas *must not* have any border or padding, or mouse coords will be wrong */
  65. canvas.emscripten {
  66. border: 0px none;
  67. background: black;
  68. width: 100%;
  69. }
  70. .spinner {
  71. height: 30px;
  72. width: 30px;
  73. margin: 0;
  74. margin-top: 20px;
  75. margin-left: 20px;
  76. display: inline-block;
  77. vertical-align: top;
  78. -webkit-animation: rotation .8s linear infinite;
  79. -moz-animation: rotation .8s linear infinite;
  80. -o-animation: rotation .8s linear infinite;
  81. animation: rotation 0.8s linear infinite;
  82. border-left: 5px solid black;
  83. border-right: 5px solid black;
  84. border-bottom: 5px solid black;
  85. border-top: 5px solid red;
  86. border-radius: 100%;
  87. background-color: rgb(245, 245, 245);
  88. }
  89. @-webkit-keyframes rotation {
  90. from {-webkit-transform: rotate(0deg);}
  91. to {-webkit-transform: rotate(360deg);}
  92. }
  93. @-moz-keyframes rotation {
  94. from {-moz-transform: rotate(0deg);}
  95. to {-moz-transform: rotate(360deg);}
  96. }
  97. @-o-keyframes rotation {
  98. from {-o-transform: rotate(0deg);}
  99. to {-o-transform: rotate(360deg);}
  100. }
  101. @keyframes rotation {
  102. from {transform: rotate(0deg);}
  103. to {transform: rotate(360deg);}
  104. }
  105. #status {
  106. display: inline-block;
  107. vertical-align: top;
  108. margin-top: 30px;
  109. margin-left: 20px;
  110. font-weight: bold;
  111. color: rgb(40, 40, 40);
  112. }
  113. #progress {
  114. height: 0px;
  115. width: 0px;
  116. }
  117. #controls {
  118. display: inline-block;
  119. float: right;
  120. vertical-align: top;
  121. margin-top: 15px;
  122. margin-right: 20px;
  123. }
  124. #output {
  125. border-left: 0px none;
  126. border-right: 0px none;
  127. border-bottom: 0px none;
  128. padding-left: 0;
  129. padding-right: 0;
  130. width: 100%;
  131. height: 140px;
  132. margin: 0 auto;
  133. margin-top: 10px;
  134. display: block;
  135. background-color: black;
  136. color: rgb(37, 174, 38);
  137. font-family: 'Lucida Console', Monaco, monospace;
  138. outline: none;
  139. }
  140. input[type=button] {
  141. background-color: lightgray;
  142. border: 4px solid darkgray;
  143. color: black;
  144. text-decoration: none;
  145. cursor: pointer;
  146. width: 140px;
  147. height: 50px;
  148. margin-left: 10px;
  149. }
  150. input[type=button]:hover {
  151. background-color: #f5f5f5ff;
  152. border-color: black;
  153. }
  154. </style>
  155. </head>
  156. <body>
  157. <div id="header">
  158. <a id="logo" href="https://www.raylib.com"></a>
  159. <div class="spinner" id='spinner'></div>
  160. <div class="emscripten" id="status">Downloading...</div>
  161. <span id='controls'>
  162. <span><input type="button" value="📜 SOURCE CODE" onclick="location.href='https://github.com/raysan5/raylib';"/></span>
  163. <span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
  164. <span><input type="button" id="btn-audio" value="🔇 MUTE" onclick="toggleAudio()"></span>
  165. </span>
  166. <div class="emscripten">
  167. <progress value="0" max="100" id="progress" hidden=1></progress>
  168. </div>
  169. </div>
  170. <div class="emscripten_border">
  171. <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
  172. </div>
  173. <textarea id="output" rows="8"></textarea>
  174. <script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
  175. <script type='text/javascript'>
  176. function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
  177. {
  178. var isSafari = false; // Not supported, navigator.userAgent access is being restricted
  179. //var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  180. var data = FS.readFile(memoryFSname);
  181. var blob;
  182. if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
  183. else blob = new Blob([data.buffer], { type: "application/octet-binary" });
  184. // NOTE: SaveAsDialog is a browser setting. For example, in Google Chrome,
  185. // in Settings/Advanced/Downloads section you have a setting:
  186. // 'Ask where to save each file before downloading' - which you can set true/false.
  187. // If you enable this setting it would always ask you and bring the SaveAsDialog
  188. saveAs(blob, localFSname);
  189. }
  190. </script>
  191. <script type='text/javascript'>
  192. var statusElement = document.querySelector('#status');
  193. var progressElement = document.querySelector('#progress');
  194. var spinnerElement = document.querySelector('#spinner');
  195. var Module = {
  196. preRun: [],
  197. postRun: [],
  198. print: (function() {
  199. var element = document.querySelector('#output');
  200. if (element) element.value = ''; // Clear browser cache
  201. return function(text) {
  202. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  203. // These replacements are necessary if you render to raw HTML
  204. //text = text.replace(/&/g, "&amp;");
  205. //text = text.replace(/</g, "&lt;");
  206. //text = text.replace(/>/g, "&gt;");
  207. //text = text.replace('\n', '<br>', 'g');
  208. console.log(text);
  209. if (element) {
  210. element.value += text + "\n";
  211. element.scrollTop = element.scrollHeight; // focus on bottom
  212. }
  213. };
  214. })(),
  215. printErr: function(text) {
  216. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  217. console.error(text);
  218. },
  219. canvas: (function() {
  220. var canvas = document.querySelector('#canvas');
  221. // As a default initial behavior, pop up an alert when webgl context is lost.
  222. // To make your application robust, you may want to override this behavior before shipping!
  223. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  224. canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  225. return canvas;
  226. })(),
  227. setStatus: function(text) {
  228. if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
  229. if (text === Module.setStatus.last.text) return;
  230. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  231. var now = Date.now();
  232. if (m && now - Module.setStatus.last.time < 30) return; // If this is a progress update, skip it if too soon
  233. Module.setStatus.last.time = now;
  234. Module.setStatus.last.text = text;
  235. if (m) {
  236. text = m[1];
  237. progressElement.value = parseInt(m[2])*100;
  238. progressElement.max = parseInt(m[4])*100;
  239. progressElement.hidden = true;
  240. spinnerElement.hidden = false;
  241. } else {
  242. progressElement.value = null;
  243. progressElement.max = null;
  244. progressElement.hidden = true;
  245. if (!text) spinnerElement.style.display = 'none';
  246. }
  247. statusElement.innerHTML = text;
  248. },
  249. totalDependencies: 0,
  250. monitorRunDependencies: function(left) {
  251. this.totalDependencies = Math.max(this.totalDependencies, left);
  252. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  253. },
  254. //noInitialRun: true
  255. };
  256. Module.setStatus('Downloading...');
  257. window.onerror = function() {
  258. Module.setStatus('Exception thrown, see JavaScript console');
  259. spinnerElement.style.display = 'none';
  260. Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
  261. };
  262. </script>
  263. <!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
  264. <script type='text/javascript'>
  265. var audioBtn = document.querySelector('#btn-audio');
  266. // An array of all contexts to resume on the page
  267. const audioContexList = [];
  268. (function() {
  269. // A proxy object to intercept AudioContexts and
  270. // add them to the array for tracking and resuming later
  271. self.AudioContext = new Proxy(self.AudioContext, {
  272. construct(target, args) {
  273. const result = new target(...args);
  274. audioContexList.push(result);
  275. if (result.state == "suspended") audioBtn.value = "🔈 RESUME";
  276. return result;
  277. }
  278. });
  279. })();
  280. function toggleAudio() {
  281. var resumed = false;
  282. audioContexList.forEach(ctx => {
  283. if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
  284. else if (ctx.state == "running") ctx.suspend();
  285. });
  286. if (resumed) audioBtn.value = "🔇 MUTE";
  287. else audioBtn.value = "🔈 RESUME";
  288. }
  289. </script>
  290. {{{ SCRIPT }}}
  291. </body>
  292. </html>