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