5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>raylib HTML5 GAME</title>
9 <meta name="title" content="raylib HTML5 GAME">
10 <meta name="description" content="New HTML5 videogame, developed using raylib videogames library">
11 <meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
12 <meta name="viewport" content="width=device-width">
14 <!-- Open Graph metatags for sharing -->
15 <meta property="og:title" content="raylib HTML5 GAME">
16 <meta property="og:image:type" content="image/png">
17 <meta property="og:image" content="https://www.raylib.com/common/img/raylib_logo.png">
18 <meta property="og:site_name" content="raylib.com">
19 <meta property="og:url" content="https://www.raylib.com/games.html">
20 <meta property="og:description" content="New HTML5 videogame, developed using raylib videogames library">
22 <!-- Twitter metatags for sharing -->
23 <meta name="twitter:card" content="summary">
24 <meta name="twitter:site" content="@raysan5">
25 <meta name="twitter:title" content="raylib HTML5 GAME">
26 <meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
27 <meta name="twitter:url" content="https://www.raylib.com/games.html">
28 <meta name="twitter:description" content="New HTML5 videogame, developed using raylib videogames library">
31 <link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
43 background-color: #888888;
46 /* NOTE: raylib logo is embedded in the page as base64 png image */
53 background-image:url('data:image/png;base64,\
54 iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADs\
55 MAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAA7JJREFUaEPtk0FyWzEMQ+37X7fZhxX4\
56 YY3AD1OKF1nkzTRlSBCCLeVBnvl/AUdaELOunPno1kts1kixdtEZKVs+xIxebBkZsVknn/L5nFGDLR8T4zVC9fX19S/+tTFijr\
57 YK4jUjbPUtqBHpnEE6PkZD7jQZV8n5Recw1XQKciZuPaEtR6UjNs5ENVGMsBVqpPtER0ZMOhpyp8m4YL4OjD9yxsyZxnQycfM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QlHnSITKzGj6DeTcZWc/3oy7h9//PF4PL4BlvsWrb6RE+oAAAAASUVORK5CYII=');
71 .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
72 div.emscripten { text-align: center; }
73 div.emscripten_border { border: 1px solid black; }
75 /* NOTE: Canvas *must not* have any border or padding, or mouse coords will be wrong */
88 display: inline-block;
90 -webkit-animation: rotation .8s linear infinite;
91 -moz-animation: rotation .8s linear infinite;
92 -o-animation: rotation .8s linear infinite;
93 animation: rotation 0.8s linear infinite;
94 border-left: 5px solid black;
95 border-right: 5px solid black;
96 border-bottom: 5px solid black;
97 border-top: 5px solid red;
99 background-color: rgb(245, 245, 245);
101 @-webkit-keyframes rotation {
102 from {-webkit-transform: rotate(0deg);}
103 to {-webkit-transform: rotate(360deg);}
105 @-moz-keyframes rotation {
106 from {-moz-transform: rotate(0deg);}
107 to {-moz-transform: rotate(360deg);}
109 @-o-keyframes rotation {
110 from {-o-transform: rotate(0deg);}
111 to {-o-transform: rotate(360deg);}
113 @keyframes rotation {
114 from {transform: rotate(0deg);}
115 to {transform: rotate(360deg);}
119 display: inline-block;
124 color: rgb(40, 40, 40);
133 display: inline-block;
146 background-color: black;
147 color: rgb(37, 174, 38);
148 font-family: 'Lucida Console', Monaco, monospace;
153 background-color: lightgray;
154 border: 4px solid darkgray;
156 text-decoration: none;
162 input[type=button]:hover {
163 background-color: #f5f5f5ff;
170 <a id="logo" href="https://www.raylib.com"></a>
172 <div class="spinner" id='spinner'></div>
173 <div class="emscripten" id="status">Downloading...</div>
176 <span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
177 <span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
180 <div class="emscripten">
181 <progress value="0" max="100" id="progress" hidden=1></progress>
185 <div class="emscripten_border">
186 <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
189 <textarea id="output" rows="8"></textarea>
191 <script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
192 <script type='text/javascript'>
193 function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
195 var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
196 var data = FS.readFile(memoryFSname);
199 if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
200 else blob = new Blob([data.buffer], { type: "application/octet-binary" });
202 // NOTE: SaveAsDialog is a browser setting. For example, in Google Chrome,
203 // in Settings/Advanced/Downloads section you have a setting:
204 // 'Ask where to save each file before downloading' - which you can set true/false.
205 // If you enable this setting it would always ask you and bring the SaveAsDialog
206 saveAs(blob, localFSname);
209 <script type='text/javascript'>
210 var statusElement = document.querySelector('#status');
211 var progressElement = document.querySelector('#progress');
212 var spinnerElement = document.querySelector('#spinner');
217 var element = document.querySelector('#output');
219 if (element) element.value = ''; // Clear browser cache
221 return function(text) {
222 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
223 // These replacements are necessary if you render to raw HTML
224 //text = text.replace(/&/g, "&");
225 //text = text.replace(/</g, "<");
226 //text = text.replace(/>/g, ">");
227 //text = text.replace('\n', '<br>', 'g');
231 element.value += text + "\n";
232 element.scrollTop = element.scrollHeight; // focus on bottom
236 printErr: function(text) {
237 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
241 canvas: (function() {
242 var canvas = document.querySelector('#canvas');
244 // As a default initial behavior, pop up an alert when webgl context is lost.
245 // To make your application robust, you may want to override this behavior before shipping!
246 // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
247 canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
251 setStatus: function(text) {
252 if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
253 if (text === Module.setStatus.last.text) return;
255 var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
256 var now = Date.now();
258 if (m && now - Module.setStatus.last.time < 30) return; // If this is a progress update, skip it if too soon
260 Module.setStatus.last.time = now;
261 Module.setStatus.last.text = text;
265 progressElement.value = parseInt(m[2])*100;
266 progressElement.max = parseInt(m[4])*100;
267 progressElement.hidden = true;
268 spinnerElement.hidden = false;
270 progressElement.value = null;
271 progressElement.max = null;
272 progressElement.hidden = true;
273 if (!text) spinnerElement.style.display = 'none';
276 statusElement.innerHTML = text;
278 totalDependencies: 0,
279 monitorRunDependencies: function(left) {
280 this.totalDependencies = Math.max(this.totalDependencies, left);
281 Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
286 Module.setStatus('Downloading...');
288 window.onerror = function() {
289 Module.setStatus('Exception thrown, see JavaScript console');
290 spinnerElement.style.display = 'none';
291 Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
295 <!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
296 <script type='text/javascript'>
297 var audioBtn = document.querySelector('#btn-audio');
299 // An array of all contexts to resume on the page
300 const audioContexList = [];
302 // A proxy object to intercept AudioContexts and
303 // add them to the array for tracking and resuming later
304 self.AudioContext = new Proxy(self.AudioContext, {
305 construct(target, args) {
306 const result = new target(...args);
307 audioContexList.push(result);
308 if (result.state == "suspended") audioBtn.value = "🔈 RESUME";
314 function toggleAudio() {
316 audioContexList.forEach(ctx => {
317 if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
318 else if (ctx.state == "running") ctx.suspend();
321 if (resumed) audioBtn.value = "🔇 SUSPEND";
322 else audioBtn.value = "🔈 RESUME";