Add files using upload-large-folder tool
Browse filesFiles changed (20)
- filestorage/gd/aiwnios/aiwnios.jsAdded
- filestorage/gd/aiwnios/index.htmlAdded+22
- filestorage/gd/georgeandtheprinter/index.htmlAdded+26
- filestorage/gd/half-life/browserfs.min.jsAdded
- filestorage/gd/half-life/client.jsAdded
- filestorage/gd/half-life/favicon.icoAdded
- filestorage/gd/half-life/index.htmlAdded+697
- filestorage/gd/half-life/menu.jsAdded
- filestorage/gd/half-life/mods.jsAdded+27
- filestorage/gd/half-life/server.jsAdded
- filestorage/gd/half-life/xash.jsAdded
- filestorage/gd/spicyfuse-runiestory/binjgb.jsAdded+21
- filestorage/gd/spicyfuse-runiestory/index.htmlAdded+34
- filestorage/gd/tetris/WallKicks.jsAdded+67
- filestorage/gd/tetris/about.htmlAdded+68
- filestorage/gd/tetris/controls.htmlAdded+129
- filestorage/gd/tetris/controlsStyles.cssAdded+113
- filestorage/gd/tetris/gameControls.jsAdded+46
- filestorage/gd/tetris/input.jsAdded+69
- filestorage/gd/tetris/jawsjs.jsAdded+1520
12345678910111213141516171819202122<!DOCTYPE html><html>
<head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body style="padding:0; margin:0; overflow: hidden; background-color: black;"> <canvas id="canvas" oncontextmenu="event.preventDefault()" style="width:640px; height:480px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)"></canvas>
<script type='text/javascript'> var Module = { canvas: (function() { return document.getElementById('canvas'); })() }; </script> <script src="aiwnios.js"></script></body>
</html>1234567891011121314151617181920212223242526<!DOCTYPE html><html lang="en-us"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>George and the Printer</title> <link rel="shortcut icon" href="TemplateData/favicon.ico"> <link rel="stylesheet" href="TemplateData/style.css"> <script src="TemplateData/UnityProgress.js"></script> <script src="Build/UnityLoader.js"></script> <script src="/js/main.js"></script> <script> var unityInstance = UnityLoader.instantiate("unityContainer", "Build/WebGL.json", {onProgress: UnityProgress}); </script> </head> <body> <div class="webgl-content"> <div id="unityContainer" style="width: 960px; height: 600px"></div> <div class="footer"> <div class="webgl-logo"></div> <div class="fullscreen" onclick="unityInstance.SetFullscreen(1)"></div> <div class="title">George and the Printer</div> </div> </div> </body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
<!DOCTYPE html><html lang="en-us">
<head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="MobileOptimized" content="640" /> <meta name="HandheldFriendly" content="true" /> <title>IXL - Dashboard</title> <script> document.addEventListener('contextmenu', event => event.preventDefault()); window.onbeforeunload = function(e) { e.preventDefault(); e.returnValue = 'Really want to quit the game?'; };
document.onkeydown = function(e) { e = e || window.event;
if (!e.ctrlKey) return;
var code = e.which || e.keyCode;
switch (code) { case 83: case 87: e.preventDefault(); e.stopPropagation(); break; } }; var a = new Audio('music.mp3'); var pashalka_count = 0;
function play_sound() { if (pashalka_count == 40) a.play(); if (pashalka_count < 100) pashalka_count += 1; } window.addEventListener('click', play_sound); window.addEventListener('keydown', play_sound); </script> <style> body { font-family: arial; margin: 0; padding: none; background-color: #555555; color: #f0b418; }
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border {}
canvas.emscripten { border: 0px none; background-image: url(xd.png); box-shadow: #ffa600 0px 0px 9px 4px; }
@-webkit-keyframes rotation { from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); } }
@-moz-keyframes rotation { from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); } }
@-o-keyframes rotation { from { -o-transform: rotate(0deg); }
to { -o-transform: rotate(360deg); } }
@keyframes rotation { from { transform: rotate(0deg); }
to { transform: rotate(360deg); } }
#controls { display: inline-block; float: right; vertical-align: top; margin-top: 5px; margin-right: 20px; }
#output { width: 100%; height: 200px; margin: 0 auto; margin-top: 10px; border-left: 0px; border-right: 0px; border-style: solid; padding-left: 0px; padding-right: 0px; display: none; background-color: black; color: rgba(0, 255, 0, 255); font-family: 'Lucida Console', Monaco, monospace; outline: none; border-color: #f0B418; }
.loader { border: 4px solid #f3f3f3; border-radius: 50%; border-top: 4px solid #ffa600; width: 16px; height: 16px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; }
@-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); } }
a.glow, a.glow:hover, a.glow:focus { text-decoration: none; color: #F0B418; text-shadow: none; -webkit-transition: 500ms linear 0s; -moz-transition: 500ms linear 0s; -o-transition: 500ms linear 0s; transition: 500ms linear 0s; outline: 0 none; cursor: default; }
a.glow:hover, a.glow:focus { color: #ffa600; text-shadow: -1px 1px 8px #ffa600, 1px -1px 8px #ffa600; }
hr { border-color: #ffa600; }
#label_file_select { padding: 1px 6px; }
input[type="file"i] { display: none; }
input[type="text"i] { color: #f0b418; background-color: #555555; border: 2px solid #f0b418; font-family: Segoe UI; font-size: 15px; transition: 0.5s all; }
* { cursor: default; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; outline: none; }
if (document.createElement("detect").style.textShadow==="") { document.getElementsByTagName("html")[0].className+=" textshadow"; } </style></head>
<body onerror=alert(event); bgcolor=#555555 text=#F0B418 link=#ffa600 vlink=#ffa600>
<script src="/assets/js/notifications.js"></script><script src="/assets/js/game-save-sync.js"></script>
<div class="emscripten_border"> <canvas style="display:none" class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> </div>
<p> <div style=width:100%;height:0px> <div style="float:left;" id="status">Downloading...</div> <div id="progress1" style="position:relative;z-index:10;display:none;float:right;width:70%;border-color:#F0B418;border-style:solid;border-width:2px;height:20px; visibility: hidden;"> <div id=progress style="text-align:center;background-color:#F0B418;border-color:#555555;border-style:solid:border-width:3px;width:50%;height:20px; visibility: hidden;"></div> </div><br> </div><br></p>
<textarea style='visibility: hidden;' id="output" rows="8" style="display: none;"></textarea> <div style='visibility: hidden;' id="asyncDialog" style="float:left"></div>
<center> <a class="glow"> <div id=optionsTitle> <h1>Xash</h1> </div> </a></center> <center> <form style=display:none id=fSettings> <a class='glow'>Select filesystem for save and restore:</a> <div id=idbHider style=display:none><label><input name=a type=radio id=rIndexedDB checked=true />IndexedDB</label><br></div> <label><input name=a type=radio id=rLocalStorage />in Local storage</label><br> <label><input name=a type=radio id=rNone />in RAM</label><br><br> <hr> <div id=zipHider style=display:none><input name=b type=radio id=rZip checked=true />ZIP archive from server </label><select id=selectZip style=display:none></select><br></div>
<label><input name=b type=radio id=rLocalZip />Local ZIP file:</label><label id="label_file_select"><input type=file name=c id=iZipFile /><a class='glow'> Select ZIP file </a></label><br><br><hr> Command-line arguments: <input name=d type=text id=iArgs value="-dev 1 -game valve" /><br><br> <a class='glow' onclick="startXash();return false;">Launch Xash!</a> <br><hr> <div id='linksPlaceholder' style=display:none>Download archives to load locally next time:</div><br> <label> <div id=pkgHider style=display:none><input name=b type=radio id=rPackage /> </label><select id=selectPkg style=display:none></select><br></div> <label> <div style='visibility: hidden;' class="loader" id=loader1></div> </form> </label>
<div style=width:100%><span id='controls'> <a style='visibility: hidden;' class="glow"><span><label id="label_show_console_log" style="display: none;"><input type="checkbox" id="show_console_log">Show Console Log</label></span></a> <a style='visibility: hidden;' class="glow"><span><label><input type="checkbox" id="resize">Resize canvas</label></span></a> <a style='visibility: hidden;' class="glow"><span><label><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer </label></span></a> <span style='visibility: hidden;'><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)"></span> </span></div>
<script type='text/javascript' src='browserfs.min.js'></script> <script type='text/javascript'> var zipMods = []; var pkgMods = []; </script>
<script type='text/javascript' src='mods.js'></script>
<script type='text/javascript'> var show_again = true; var statusElement = document.getElementById('status'); var progressElement = document.getElementById('progress'); var asyncDialog = document.getElementById('asyncDialog'); var myerrorbuf = '' var myerrordate = new Date(); var mounted = false; var gamedir = 'valve'; var moduleCount = 0; //var mem = 150; var mfs; var zipSize;
if (!ArrayBuffer['isView']) { ArrayBuffer.isView = function(a) { return a !== null && typeof(a) === "object" && a['buffer'] instanceof ArrayBuffer; };
}
showElement('optionsTitle', false);
function prepareSelects() { var len = zipMods.length; var select = document.getElementById('selectZip'); if (len) { showElement('zipHider', true);
if (len > 1) { var links = ''; for (var i = 0; i < len; i++) { select.options[i] = new Option(zipMods[i][1], zipMods[i][0]); links += '<br><a class="glow" onclick=location.href="' + zipMods[i][0] + '">' + zipMods[i][1] + '</a>'; } select.style.display = 'block'; document.getElementById('linksPlaceholder').innerHTML += links; } } else document.getElementById('rZip').checked = false; len = pkgMods.length; select = document.getElementById('selectPkg'); if (len) { showElement('pkgHider', true);
if (len > 1) { for (var i = 0; i < len; i++) select.options[i] = new Option(pkgMods[i][1], pkgMods[i][0]); //select.style.display = 'block'; } } else document.getElementById('rPackage').checked = false;
if (!zipMods.length && !len) { document.getElementById('rLocalZip').checked = true; showElement('rLocalZip', false); } }
try { mem = Math.round(window.location.hash.substring(1)); } catch (e) {};
var Module = { TOTAL_MEMORY: mem * 1024 * 1024, preRun: [], postRun: [], print: (function() { var element = document.getElementById('output'); if (element) element.value = ''; return function(text) { if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); if (text) { myerrorbuf += text + '\n'; console.log(text); if (text == "exit(0)") { document.getElementById('canvas').style.display = "none"; setTimeout(function(){ location.reload(); }, 1000); } else if (text == "shader success") { pashalka_count = 100; a.pause(); document.getElementById('canvas').style.display = "block"; } else { } } if (element) { if (element.value.length > 65536) element.value = element.value.substring(512) + myerrorbuf; else element.value += myerrorbuf; element.scrollTop = element.scrollHeight; // focus on bottom } myerrorbuf = '' }; })(), printErr: function(text) { if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); if (0) { // XXX disabled for safety typeof dump == 'function') { dump(text + '\n'); // fast, straight to the real console } else { if (myerrorbuf.length > 2048) myerrorbuf = 'some lines skipped\n' + myerrorbuf.substring(512); myerrorbuf += text + '\n'; if (new Date() - myerrordate > 3000) { myerrordate = new Date(); Module.print(); } } }, canvas: (function() { var canvas = document.getElementById('canvas'); canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas; })(), setStatus: function(text) { if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; if (text === Module.setStatus.text) return; if (new Date() - myerrordate > 3000) { myerrordate = new Date(); Module.print(); }
statusElement.innerHTML = text; if (progressElement) { var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
if (m) { var progress = Math.round(parseInt(m[2]) * 100 / parseInt(m[4])); progressElement.style.color = progress > 5 ? '#303030' : '#aaa000'; progressElement.style.width = progressElement.innerHTML = '' + progress + '%'; } showElement('progress1', !!m); } }, totalDependencies: 0, monitorRunDependencies: function(left) { this.totalDependencies = Math.max(this.totalDependencies, left); if (left) Module.setStatus('Preparing... (' + (this.totalDependencies - left) + '/' + this.totalDependencies + ')'); } }; window.onerror = function(event) { if (mounted) FS.syncfs(false, function(err) { Module.print('Saving IDBFS: ' + err); }); if (('' + event).indexOf('SimulateInfiniteLoop') > 0) return; var text = 'Exception thrown: ' + event; text = text.replace(/&/g, "&"); text = text.replace(/</g, "<"); text = text.replace(/>/g, ">"); text = text.replace('\n', '<br>', 'g'); Module.setStatus(text); Module.print('Exception thrown: ' + event); };
function haltRun() {}
var savedRun;
function radioChecked(id) { var r = document.getElementById('r' + id); if (r) return r.checked; return false; }
function showElement(id, show) { var e = document.getElementById(id); if (!e) return; e.style.display = show ? 'block' : 'none'; } Module.setStatus('Downloading...');
function startXash() { showElement('loader1', false); showElement('optionsTitle', false); showElement('fSettings', false); setupFS(); Module.arguments = document.getElementById('iArgs').value.split(' '); Module.run = run = savedRun; if (radioChecked('Zip')) { const zipper = document.getElementById('selectZip'); if (zipMods.length > 1) { var mod_parts = [zipMods[0][3], zipMods[0][4], zipMods[0][2]]; for (var i = 0; i < zipMods.length; i++) { if (zipMods[i][0] == zipper.value) { mod_parts = [zipMods[i][3], zipMods[i][4], zipMods[i][2]]; break; } } fetchZIP(zipper.value, savedRun, mod_parts[0], mod_parts[1], mod_parts[2]); } else { fetchZIP(zipMods[0][0], savedRun, zipMods[0][3]); } } else if ((!zipMods.length && !pkgMods.length) || radioChecked('LocalZip')) { var reader = new FileReader(); reader.onload = function() { mountZIP(reader.result); Module.print("Loaded zip data"); savedRun(); }; reader.readAsArrayBuffer(document.getElementById('iZipFile').files[0]); } else if (radioChecked('Package')) { var script = document.createElement('script'); script.onload = savedRun; document.body.appendChild(script); script.src = pkgMods.length > 1 ? document.getElementById('selectPkg').value : pkgMods[0][0]; }
window.addEventListener("beforeunload", function(e) { var confirmationMessage = 'Leave the game?';
(e || window.event).returnValue = confirmationMessage; //Gecko + IE return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc. }); }
function mountZIP(data) { var Buffer = BrowserFS.BFSRequire('buffer').Buffer; mfs.mount('/zip', new BrowserFS.FileSystem.ZipFS(Buffer.from(data))); FS.mount(new BrowserFS.EmscriptenFS(), { root: '/zip' }, '/rodir'); }
function fetchZIP(packageName, cb, parts = 0, size_of_parts = 0, total_size = 0) { if (parts == 0) { var xhr = new XMLHttpRequest(); xhr.open('GET', packageName, true); xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) { var url = packageName; var size; if (event.total) size = event.total; else size = zipMods[document.getElementById('selectZip').selectedIndex][2]; if (event.loaded) { var total = size; var loaded = event.loaded; var num = 0; if (Module['setStatus']) Module['setStatus']('Downloading data...'); } else if (!Module.dataFileDownloads) { if (Module['setStatus']) Module['setStatus']('Downloading data...'); } }; xhr.onerror = function(event) { throw new Error("NetworkError"); } xhr.onload = function(event) { if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 mountZIP(xhr.response); cb(); } else { throw new Error(xhr.statusText + " : " + xhr.responseURL); } }; xhr.send(null); } else { var buffers = new Uint8Array(total_size); var finished = 0; for (var i = 0; i < parts; i++) { const cur = i; const no_ext = packageName.slice(0, -4); const url1 = no_ext + '_out/' + no_ext + '-' + cur + '.zip'; console.log(url1); const xhr = new XMLHttpRequest(); xhr.open('GET', url1, true); xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) { if (event.loaded) { var loaded = event.loaded; if (Module['setStatus']) Module['setStatus']('Downloading data... (' + ((finished * size_of_parts) + loaded) + '/' + total_size + ')'); } else if (!Module.dataFileDownloads) { if (Module['setStatus']) Module['setStatus']('Downloading data...'); } }; xhr.onerror = function(event) { throw new Error("NetworkError"); } xhr.onload = function(event) { if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 finished++; buffers.set(new Uint8Array(xhr.response), cur * size_of_parts); if (finished == parts) { mountZIP(buffers); cb(); } } else { throw new Error(xhr.statusText + " : " + xhr.responseURL); } }; xhr.send(null); } } }
function setupFS() { FS.mkdir('/rodir'); FS.mkdir('/xash'); try { mfs = new BrowserFS.FileSystem.MountableFileSystem(); BrowserFS.initialize(mfs); } catch (e) { mfs = undefined; Module.print('Failed to initialize BrowserFS: ' + e); }
if (radioChecked('IndexedDB')) { FS.mount(IDBFS, {}, '/xash'); FS.syncfs(true, function(err) { if (err) Module.print('Loading IDBFS: ' + err); }); mounted = true; }
if (radioChecked('LocalStorage') && mfs) { mfs.mount('/ls', new BrowserFS.FileSystem.LocalStorage()); FS.mount(new BrowserFS.EmscriptenFS(), { root: '/ls' }, '/xash'); Module.print('LocalStorage mounted'); }
FS.chdir('/xash/'); }
function skipRun() { savedRun = run; Module.run = haltRun; run = haltRun;
Module.setStatus("Xash3D downloaded!"); showElement('loader1', false); showElement('optionsTitle', true);
if (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) showElement('idbHider', true); prepareSelects(); showElement('fSettings', true);
ENV.XASH3D_GAMEDIR = gamedir; ENV.XASH3D_RODIR = '/rodir'
function loadModule(name) { var script = document.createElement('script'); script.onload = function() { moduleCount++; if (moduleCount == 3) { Module.setStatus("Scripts downloaded!"); } }; document.body.appendChild(script); script.src = name + ".js"; }
loadModule("server"); loadModule("client"); loadModule("menu"); };
Module.preInit = [skipRun]; Module.websocket = []; //Module.websocket.url = 'wsproxy://the-swank.pp.ua:3000/' Module.websocket.url = 'wsproxy://4.tcp.ngrok.io:10657/'; ENV = []; </script>
<script> (function() { var memoryInitializer = 'xash.html.mem'; if (typeof Module['locateFile'] === 'function') { memoryInitializer = Module['locateFile'](memoryInitializer); } else if (Module['memoryInitializerPrefixURL']) { memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer; } var xhr = Module['memoryInitializerRequest'] = new XMLHttpRequest(); xhr.open('GET', memoryInitializer, true); xhr.responseType = 'arraybuffer'; xhr.send(null); })();
var script = document.createElement('script'); script.src = "xash.js"; document.body.appendChild(script); </script> <script> document.getElementById('show_console_log').addEventListener('change', function() { if (document.getElementById('show_console_log').checked) document.getElementById('output').style.display = "block"; else document.getElementById('output').style.display = "none"; }); document.getElementById('label_show_console_log').style.display = "inline-block"; </script></body>
</html>123456789101112131415161718192021222324252627zipMods = [ ['halva_en.zip', 'Half-Life (214M)', 214283501, 21, 10485760], ['opposing_force_en.zip', 'Opposing Force (221M)', 221191140, 22, 10485760]];
pkgMods = [];var selectZip=document.getElementById('selectZip');var iArgs=document.getElementById('iArgs');selectZip.addEventListener('change', function(){ if(selectZip.value=="halva_en.zip") { iArgs.value="-dev 1 -game valve"; } else if(selectZip.value=="opposing_force_en.zip") { iArgs.value="-dev 1 -game gearbox"; } else if(selectZip.value=="halva_rus.zip") { iArgs.value="-dev 1 -game valve"; } else if(selectZip.value=="opposing_force_rus.zip") { iArgs.value="-dev 1 -game valve"; }});123456789101112131415161718192021
var Binjgb = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
return (
function(Binjgb) {
Binjgb = Binjgb || {};
var Module=typeof Binjgb!=="undefined"?Binjgb:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx<endPtr){var u0=heap[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heap[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heap[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heap[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}function hasPrefix(str,prefix){return String.prototype.startsWith?str.startsWith(prefix):str.indexOf(prefix)===0}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return hasPrefix(filename,dataURIPrefix)}var wasmBinaryFile="binjgb.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["g"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["H"];removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync().catch(readyPromiseReject);return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function abortOnCannotGrowMemory(requestedSize){abort("OOM")}function _emscripten_resize_heap(requestedSize){abortOnCannotGrowMemory(requestedSize)}function _exit(status){exit(status)}var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function _fd_close(fd){return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAP32[iov+i*8>>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j<len;j++){SYSCALLS.printChar(fd,HEAPU8[ptr+j])}num+=len}HEAP32[pnum>>2]=num;return 0}var asmLibraryArg={"d":_emscripten_memcpy_big,"e":_emscripten_resize_heap,"b":_exit,"f":_fd_close,"c":_fd_seek,"a":_fd_write};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["h"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["i"]).apply(null,arguments)};var _emulator_set_builtin_palette=Module["_emulator_set_builtin_palette"]=function(){return(_emulator_set_builtin_palette=Module["_emulator_set_builtin_palette"]=Module["asm"]["j"]).apply(null,arguments)};var _emulator_was_ext_ram_updated=Module["_emulator_was_ext_ram_updated"]=function(){return(_emulator_was_ext_ram_updated=Module["_emulator_was_ext_ram_updated"]=Module["asm"]["k"]).apply(null,arguments)};var _emulator_read_ext_ram=Module["_emulator_read_ext_ram"]=function(){return(_emulator_read_ext_ram=Module["_emulator_read_ext_ram"]=Module["asm"]["l"]).apply(null,arguments)};var _emulator_write_ext_ram=Module["_emulator_write_ext_ram"]=function(){return(_emulator_write_ext_ram=Module["_emulator_write_ext_ram"]=Module["asm"]["m"]).apply(null,arguments)};var _file_data_delete=Module["_file_data_delete"]=function(){return(_file_data_delete=Module["_file_data_delete"]=Module["asm"]["n"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["o"]).apply(null,arguments)};var _emulator_delete=Module["_emulator_delete"]=function(){return(_emulator_delete=Module["_emulator_delete"]=Module["asm"]["p"]).apply(null,arguments)};var _emulator_get_PC=Module["_emulator_get_PC"]=function(){return(_emulator_get_PC=Module["_emulator_get_PC"]=Module["asm"]["q"]).apply(null,arguments)};var _emulator_get_A=Module["_emulator_get_A"]=function(){return(_emulator_get_A=Module["_emulator_get_A"]=Module["asm"]["r"]).apply(null,arguments)};var _emulator_get_BC=Module["_emulator_get_BC"]=function(){return(_emulator_get_BC=Module["_emulator_get_BC"]=Module["asm"]["s"]).apply(null,arguments)};var _emulator_get_DE=Module["_emulator_get_DE"]=function(){return(_emulator_get_DE=Module["_emulator_get_DE"]=Module["asm"]["t"]).apply(null,arguments)};var _emulator_get_HL=Module["_emulator_get_HL"]=function(){return(_emulator_get_HL=Module["_emulator_get_HL"]=Module["asm"]["u"]).apply(null,arguments)};var _emulator_get_F=Module["_emulator_get_F"]=function(){return(_emulator_get_F=Module["_emulator_get_F"]=Module["asm"]["v"]).apply(null,arguments)};var _emulator_get_SP=Module["_emulator_get_SP"]=function(){return(_emulator_get_SP=Module["_emulator_get_SP"]=Module["asm"]["w"]).apply(null,arguments)};var _emulator_set_PC=Module["_emulator_set_PC"]=function(){return(_emulator_set_PC=Module["_emulator_set_PC"]=Module["asm"]["x"]).apply(null,arguments)};var _emulator_set_breakpoint=Module["_emulator_set_breakpoint"]=function(){return(_emulator_set_breakpoint=Module["_emulator_set_breakpoint"]=Module["asm"]["y"]).apply(null,arguments)};var _emulator_clear_breakpoints=Module["_emulator_clear_breakpoints"]=function(){return(_emulator_clear_breakpoints=Module["_emulator_clear_breakpoints"]=Module["asm"]["z"]).apply(null,arguments)};var _emulator_render_vram=Module["_emulator_render_vram"]=function(){return(_emulator_render_vram=Module["_emulator_render_vram"]=Module["asm"]["A"]).apply(null,arguments)};var _emulator_render_background=Module["_emulator_render_background"]=function(){return(_emulator_render_background=Module["_emulator_render_background"]=Module["asm"]["B"]).apply(null,arguments)};var _emulator_get_wram_ptr=Module["_emulator_get_wram_ptr"]=function(){return(_emulator_get_wram_ptr=Module["_emulator_get_wram_ptr"]=Module["asm"]["C"]).apply(null,arguments)};var _emulator_get_hram_ptr=Module["_emulator_get_hram_ptr"]=function(){return(_emulator_get_hram_ptr=Module["_emulator_get_hram_ptr"]=Module["asm"]["D"]).apply(null,arguments)};var _emulator_read_mem=Module["_emulator_read_mem"]=function(){return(_emulator_read_mem=Module["_emulator_read_mem"]=Module["asm"]["E"]).apply(null,arguments)};var _emulator_write_mem=Module["_emulator_write_mem"]=function(){return(_emulator_write_mem=Module["_emulator_write_mem"]=Module["asm"]["F"]).apply(null,arguments)};var _set_audio_channel_mute=Module["_set_audio_channel_mute"]=function(){return(_set_audio_channel_mute=Module["_set_audio_channel_mute"]=Module["asm"]["G"]).apply(null,arguments)};var _joypad_new=Module["_joypad_new"]=function(){return(_joypad_new=Module["_joypad_new"]=Module["asm"]["I"]).apply(null,arguments)};var _joypad_delete=Module["_joypad_delete"]=function(){return(_joypad_delete=Module["_joypad_delete"]=Module["asm"]["J"]).apply(null,arguments)};var _rewind_append=Module["_rewind_append"]=function(){return(_rewind_append=Module["_rewind_append"]=Module["asm"]["K"]).apply(null,arguments)};var _rewind_delete=Module["_rewind_delete"]=function(){return(_rewind_delete=Module["_rewind_delete"]=Module["asm"]["L"]).apply(null,arguments)};var _emulator_new_simple=Module["_emulator_new_simple"]=function(){return(_emulator_new_simple=Module["_emulator_new_simple"]=Module["asm"]["M"]).apply(null,arguments)};var _emulator_get_ticks_f64=Module["_emulator_get_ticks_f64"]=function(){return(_emulator_get_ticks_f64=Module["_emulator_get_ticks_f64"]=Module["asm"]["N"]).apply(null,arguments)};var _emulator_run_until_f64=Module["_emulator_run_until_f64"]=function(){return(_emulator_run_until_f64=Module["_emulator_run_until_f64"]=Module["asm"]["O"]).apply(null,arguments)};var _rewind_get_newest_ticks_f64=Module["_rewind_get_newest_ticks_f64"]=function(){return(_rewind_get_newest_ticks_f64=Module["_rewind_get_newest_ticks_f64"]=Module["asm"]["P"]).apply(null,arguments)};var _rewind_get_oldest_ticks_f64=Module["_rewind_get_oldest_ticks_f64"]=function(){return(_rewind_get_oldest_ticks_f64=Module["_rewind_get_oldest_ticks_f64"]=Module["asm"]["Q"]).apply(null,arguments)};var _emulator_set_default_joypad_callback=Module["_emulator_set_default_joypad_callback"]=function(){return(_emulator_set_default_joypad_callback=Module["_emulator_set_default_joypad_callback"]=Module["asm"]["R"]).apply(null,arguments)};var _emulator_set_bw_palette_simple=Module["_emulator_set_bw_palette_simple"]=function(){return(_emulator_set_bw_palette_simple=Module["_emulator_set_bw_palette_simple"]=Module["asm"]["S"]).apply(null,arguments)};var _rewind_new_simple=Module["_rewind_new_simple"]=function(){return(_rewind_new_simple=Module["_rewind_new_simple"]=Module["asm"]["T"]).apply(null,arguments)};var _rewind_begin=Module["_rewind_begin"]=function(){return(_rewind_begin=Module["_rewind_begin"]=Module["asm"]["U"]).apply(null,arguments)};var _emulator_set_rewind_joypad_callback=Module["_emulator_set_rewind_joypad_callback"]=function(){return(_emulator_set_rewind_joypad_callback=Module["_emulator_set_rewind_joypad_callback"]=Module["asm"]["V"]).apply(null,arguments)};var _rewind_to_ticks_wrapper=Module["_rewind_to_ticks_wrapper"]=function(){return(_rewind_to_ticks_wrapper=Module["_rewind_to_ticks_wrapper"]=Module["asm"]["W"]).apply(null,arguments)};var _rewind_end=Module["_rewind_end"]=function(){return(_rewind_end=Module["_rewind_end"]=Module["asm"]["X"]).apply(null,arguments)};var _set_joyp_up=Module["_set_joyp_up"]=function(){return(_set_joyp_up=Module["_set_joyp_up"]=Module["asm"]["Y"]).apply(null,arguments)};var _set_joyp_down=Module["_set_joyp_down"]=function(){return(_set_joyp_down=Module["_set_joyp_down"]=Module["asm"]["Z"]).apply(null,arguments)};var _set_joyp_left=Module["_set_joyp_left"]=function(){return(_set_joyp_left=Module["_set_joyp_left"]=Module["asm"]["_"]).apply(null,arguments)};var _set_joyp_right=Module["_set_joyp_right"]=function(){return(_set_joyp_right=Module["_set_joyp_right"]=Module["asm"]["$"]).apply(null,arguments)};var _set_joyp_B=Module["_set_joyp_B"]=function(){return(_set_joyp_B=Module["_set_joyp_B"]=Module["asm"]["aa"]).apply(null,arguments)};var _set_joyp_A=Module["_set_joyp_A"]=function(){return(_set_joyp_A=Module["_set_joyp_A"]=Module["asm"]["ba"]).apply(null,arguments)};var _set_joyp_start=Module["_set_joyp_start"]=function(){return(_set_joyp_start=Module["_set_joyp_start"]=Module["asm"]["ca"]).apply(null,arguments)};var _set_joyp_select=Module["_set_joyp_select"]=function(){return(_set_joyp_select=Module["_set_joyp_select"]=Module["asm"]["da"]).apply(null,arguments)};var _get_frame_buffer_ptr=Module["_get_frame_buffer_ptr"]=function(){return(_get_frame_buffer_ptr=Module["_get_frame_buffer_ptr"]=Module["asm"]["ea"]).apply(null,arguments)};var _get_frame_buffer_size=Module["_get_frame_buffer_size"]=function(){return(_get_frame_buffer_size=Module["_get_frame_buffer_size"]=Module["asm"]["fa"]).apply(null,arguments)};var _get_sgb_frame_buffer_ptr=Module["_get_sgb_frame_buffer_ptr"]=function(){return(_get_sgb_frame_buffer_ptr=Module["_get_sgb_frame_buffer_ptr"]=Module["asm"]["ga"]).apply(null,arguments)};var _get_sgb_frame_buffer_size=Module["_get_sgb_frame_buffer_size"]=function(){return(_get_sgb_frame_buffer_size=Module["_get_sgb_frame_buffer_size"]=Module["asm"]["ha"]).apply(null,arguments)};var _get_audio_buffer_ptr=Module["_get_audio_buffer_ptr"]=function(){return(_get_audio_buffer_ptr=Module["_get_audio_buffer_ptr"]=Module["asm"]["ia"]).apply(null,arguments)};var _get_audio_buffer_capacity=Module["_get_audio_buffer_capacity"]=function(){return(_get_audio_buffer_capacity=Module["_get_audio_buffer_capacity"]=Module["asm"]["ja"]).apply(null,arguments)};var _ext_ram_file_data_new=Module["_ext_ram_file_data_new"]=function(){return(_ext_ram_file_data_new=Module["_ext_ram_file_data_new"]=Module["asm"]["ka"]).apply(null,arguments)};var _get_file_data_ptr=Module["_get_file_data_ptr"]=function(){return(_get_file_data_ptr=Module["_get_file_data_ptr"]=Module["asm"]["la"]).apply(null,arguments)};var _get_file_data_size=Module["_get_file_data_size"]=function(){return(_get_file_data_size=Module["_get_file_data_size"]=Module["asm"]["ma"]).apply(null,arguments)};var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status);ABORT=true}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
return Binjgb.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = Binjgb;
else if (typeof define === 'function' && define['amd'])
define([], function() { return Binjgb; });
else if (typeof exports === 'object')
exports["Binjgb"] = Binjgb;12345678910111213141516171819202122232425262728293031323334<!DOCTYPE html>
<html><head><meta charset="utf-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta content="width=device-width, initial-scale=1" name="viewport"/><link href="css/style.css" rel="stylesheet"/><title>Runiework</title><meta content="spicyfuse" name="author"/><style type="text/css"> body { background-color:#undefined; }</style></head><body><div id="game"><canvas height="224" id="mainCanvas" width="256">No Canvas Support</canvas></div><div id="controller"><div id="controller_dpad"><div id="controller_left"></div><div id="controller_right"></div><div id="controller_up"></div><div id="controller_down"></div></div><div class="capsuleBtn" id="controller_select">Select</div><div class="capsuleBtn" id="controller_start">Start</div><div class="roundBtn" id="controller_b">B</div><div class="roundBtn" id="controller_a">A</div></div><script> const customControls = {"a":["Alt","x",".","k"],"b":["Control","z",",","j"],"start":["Enter"," ","1"],"select":["Shift","2"]} </script><script src="binjgb.js"></script><script src="js/script.js"></script></body></html>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667var WALL_KICK_OFFSETS = {};
/*0 -> starting orientation1 -> 1 turn cw2 -> 2 turns3-> 1 turn ccw
non-I blocksL->2 ( 0, 0) (-1, 0) (-1,-1) ( 0,+2) (-1,+2)L->0 ( 0, 0) (-1, 0) (-1,-1) ( 0,+2) (-1,+2)2->R ( 0, 0) (-1, 0) (-1,+1) ( 0,-2) (-1,-2)2->L ( 0, 0) (+1, 0) (+1,+1) ( 0,-2) (+1,-2)R->0 ( 0, 0) (+1, 0) (+1,-1) ( 0,+2) (+1,+2)R->2 ( 0, 0) (+1, 0) (+1,-1) ( 0,+2) (+1,+2)0->L ( 0, 0) (+1, 0) (+1,+1) ( 0,-2) (+1,-2)0->R ( 0, 0) (-1, 0) (-1,+1) ( 0,-2) (-1,-2)
I block0->R ( 0, 0) (-2, 0) (+1, 0) (-2,-1) (+1,+2)0->L ( 0, 0) (-1, 0) (+2, 0) (-1,+2) (+2,-1)
R->2 ( 0, 0) (-1, 0) (+2, 0) (-1,+2) (+2,-1)R->0 ( 0, 0) (+2, 0) (-1, 0) (+2,+1) (-1,-2)
2->L ( 0, 0) (+2, 0) (-1, 0) (+2,+1) (-1,-2)2->R ( 0, 0) (+1, 0) (-2, 0) (+1,-2) (-2,+1)
L->0 ( 0, 0) (+1, 0) (-2, 0) (+1,-2) (-2,+1)L->2 ( 0, 0) (-2, 0) (+1, 0) (-2,-1) (+1,+2)*/
WALL_KICK_OFFSETS.standard = [ { cw: [{x:0,y:0}, {x:-1,y:0}, {x:-1,y:-1}, {x:0,y:2}, {x:-1,y:2}], ccw: [{x:0,y:0}, {x:1,y:0}, {x:1,y:-1}, {x:0,y:2}, {x:1,y:2}] },{ cw: [{x:0,y:0}, {x:1,y:0}, {x:1,y:1}, {x:0,y:-2}, {x:1,y:-2}], ccw: [{x:0,y:0}, {x:1,y:0}, {x:1,y:1}, {x:0,y:-2}, {x:1,y:-2}] },{ cw: [{x:0, y:0}, {x:1,y:0}, {x:1,y:-1}, {x:0,y:2}, {x:1,y:2}], ccw: [{x:0, y:0}, {x:-1, y:0}, {x:-1,y:-1}, {x:0,y:2}, {x:-1,y:2}] },{ cw: [{x:0,y:0}, {x:-1,y:0}, {x:-1,y:1}, {x:0,y:-2}, {x:-1,y:-2}], ccw: [{x:0,y:0}, {x:-1,y:0}, {x:-1,y:1}, {x:0,y:-2}, {x:-1,y:-2}] }];
WALL_KICK_OFFSETS.i_block = [ { cw: [{x:0,y:0}, {x:-2,y:0}, {x:1,y:0}, {x:-2,y:1}, {x:1,y:-2}], ccw: [{x:0,y:0}, {x:-1,y:0}, {x:2,y:0}, {x:-1,y:-2}, {x:2,y:1}] },{ cw: [{x:0,y:0}, {x:-1,y:0}, {x:2,y:0}, {x:-1,y:-2}, {x:2,y:1}], ccw: [{x:0,y:0}, {x:2,y:0}, {x:-1,y:0}, {x:2,y:-1}, {x:-1,y:2}] },{ cw: [{x:0,y:0}, {x:2,y:0}, {x:-1,y:0}, {x:2,y:-1}, {x:-1,y:2}], ccw: [{x:0,y:0}, {x:1,y:0}, {x:-2,y:0}, {x:1,y:2}, {x:-2,y:-1}] },{ cw: [{x:0,y:0}, {x:1,y:0}, {x:-2,y:0}, {x:1,y:2}, {x:-2,y:1}], ccw: [{x:0,y:0}, {x:-2,y:0}, {x:1,y:0}, {x:-2,y:1}, {x:1,y:-2}] }
];
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768<html> <head> <title>IXL - Dashboard</title> <script src="/js/all.min.js"></script>
<link href="//fonts.googleapis.com/css?family=VT323" rel="stylesheet" type="text/css" /> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body>
<table border="0" class="mainTable"> <tr> <td class="menuCell"> <div class="menu"> <img class="menuLogo" src="media/background/logo.png"></img> <br/><br/> <a href="index.html" class="bareLink"> <div class="menuItem">Play TwitchTetris</div> </a> <br/> <a href="controls.html" class="bareLink"> <div class="menuItem">Controls Options</div> </a> <br/> <a href="highScores.html" class="bareLink"> <div class="menuItem">High Scores</div> </a> <br/> <a href="about.html" class="bareLink"> <div class="menuItem selectedMenuItem">About TwitchTetris</div> </a> <br/> <a href="http://www.leighpauls.com" class="bareLink"> <div class="menuItem">About the Developer</div> </a> <br/>
<div class="instructions"> <b> > TwitchTetris --help </b> <p>Use the keyboard controls to rotate and move the blocks as they fall</p> <p>Place the blocks to form horizontal lines, which will be removed and make all the blocks above fall down. If the blocks reach the top of the screen, the game is over!</p> <p>Clear multiple lines at a time, or clear lines in consective moves to earn more points.</p> </div>
</div> </td> <td class="contentCell"> <div class="aboutText"> <b> > man TwitchTeteris</b><br/> <p>TwitchTetris is an open-source implementation of Tetris, the classic falling-block game that we all know and love, designed for those who demand the best performace from their tetris game.</p> <p>TwitchTetris aims to be the fastest implementation of Tetris to be played within a browser. This is possible because it's implemented completely in Html5/JavaScript. It was developed out of the frustration of inconsistent performance of Flash plugins across multiple Operating Systems and Browsers, and the sad state of other available Html5 Tetris games. TwitchTetris should have the fastest reaction time to user input of any complete Tetris implementation, and should perform the most consistently over all modern browsers.</p> <p>This project is still in the infancy of development. Please go to <a href="http://code.google.com/p/html5tetris/">the google code page</a> to report <i>any</i> bugs, problems, or suggestions that you have for the game. Contributions from other developers are also welcome.</p> <p>While TwitchTetris is not deisgned to generate revenue, ads are displayed on this website in order to cover the potential cost incurring high traffic. There are no plans to expand advertising past one or 2 ads per page, and obtrusive ads which make users wait to play the game will never be shown on this website.</p>
</div> </td> </tr> </table>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129<html> <head> <title>IXL - Dashboard</title> <script src="/js/all.min.js"></script>
<link href="//fonts.googleapis.com/css?family=VT323" rel="stylesheet" type="text/css" /> <link href="styles.css" rel="stylesheet" type="text/css" /> <link href="controlsStyles.css" rel="stylesheet" type="text/css" />
<script src="jawsjs.js" type="text/javascript"></script> <script src="cookie.js" type="text/javascript"></script> <script src="input.js" type="text/javascript"></script> <script src="controls.js" type="text/javascript"></script> </head> <body onload="onControlsLoad();"> <table border="0" class="mainTable"> <tr> <td class="menuCell"> <div class="menu"> <img class="menuLogo" src="media/background/logo.png"></img> <br/><br/> <a href="index.html" class="bareLink"> <div class="menuItem">Play TwitchTetris</div> </a> <br/> <a href="controls.html" class="bareLink"> <div class="menuItem selectedMenuItem">Controls Options</div> </a> <br/> <a href="highScores.html" class="bareLink"> <div class="menuItem">High Scores</div> </a> <br/> <a href="about.html" class="bareLink"> <div class="menuItem">About TwitchTetris</div> </a> <br/> <a href="http://www.leighpauls.com" class="bareLink"> <div class="menuItem">About the Developer</div> </a> <br/>
<div class="instructions"> <b> > TwitchTetris --help </b> <p>Use the keyboard controls to rotate and move the blocks as they fall</p> <p>Place the blocks to form horizontal lines, which will be removed and make all the blocks above fall down. If the blocks reach the top of the screen, the game is over!</p> <p>Clear multiple lines at a time, or clear lines in consective moves to earn more points.</p> </div>
</div> </td> <td class="contentCell"> <canvas id="dummyCanvas" height="0px" width="0px"></canvas> <div class="controlsArea"> <div class="enableCustomDiv"> Do you want to use a custom control scheme? <br/> <br/> <form> <input type="radio" name="controlStyle" id="defaultRadio" onchange="setDefaultControls();"/> <label for="defaultRadio">Default Controls</label><br/> <input type="radio" name="controlStyle" id="customRadio" onchange="configureCustomControls();"/> <label for="customRadio">Custom Controls</label><br/> </form> <br/> <div id="instructionsDefault" class="withDisplay"> To change your controls, select "Custom Controls" from above. </div> <div id="instructionsCustom" class="noDisplay"> Click on the fields on the right to set your controls. </div> <div id="instructionsPending" class="noDisplay"> Press a key to set this field... </div> <br/> </div> <div class="customControlsDiv"> <div class="controlsUnit" id="rotateLeftDiv" onclick="controlsUnitClicked('rotateLeft');"> Rotate Left: <span id="rotateLeftValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="rotateRightDiv" onclick="controlsUnitClicked('rotateRight');"> Rotate Right: <span id="rotateRightValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="shiftLeftDiv" onclick="controlsUnitClicked('shiftLeft');"> Shift Left: <span id="shiftLeftValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="shiftRightDiv" onclick="controlsUnitClicked('shiftRight');"> Shift Right: <span id="shiftRightValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="softDropDiv" onclick="controlsUnitClicked('softDrop');"> Soft Drop: <span id="softDropValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="hardDropDiv" onclick="controlsUnitClicked('hardDrop');"> Hard Drop: <span id="hardDropValue" class="controlsValue"></span> </div> <div class="controlsUnit" id="swapDiv" onclick="controlsUnitClicked('swap');"> Swap Peice: <span id="swapValue" class="controlsValue"></span> </div> </div>
<div class="autoRepeatArea"> Auto-Repeat Times:<br/> <button onclick="resetAutoRepeat();">Reset Auto-Repeat</button>
<div class="autoRepeatForm"> <div class="autoRepeatDiv"> AutoRepeat: <span id="autoRepeatValue"></span> ms <br/> <input id="autoRepeatRange" type="range" min="15" max="300" value="50" step="5" onchange="updateAutoRepeat();"/> </div> <div class="thresholdDiv"> Repeat Charge: <span id="thresholdValue"></span> ms <br/> <input id="thresholdRange" type="range" min="15" max="500" value="200" step="5" onchange="updateThreshold();"/> </div> </div> </div>
</div> </td> </tr> </table>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113.customControlsDiv{ position: absolute; top: 0px; right: 0px;}
.controlsArea{ padding: 5px; width: 580; position: relative;}
.controlsUnit{ margin: 10px 5px; font-size: 16px; font-family: VT323; color: #008000; background-color: #000d00; border: 1px solid #008000; border-radius: 5px; padding: 5px 10px; width: 200px;}
.controlsUnit:hover{ cursor: pointer; background-color: #008000; color: #000d00;}
.controlsUnitPending{ cursor: pointer; background-color: #008000; color: #000d00; font-weight: bold;}
.enableCustomDiv{ margin: 10px 5px; font-size: 16px; font-family: VT323; color: #008000; background-color: #000d00; border: 1px solid #008000; border-radius: 5px; padding: 5px 10px; width: 300px; height: 245px; position: absolute; top: 0px; left: 0px;}
.controlsValue{ float: right;}
.noDisplay{ display: none;}
.withDisplay{ display: inline;}
.autoRepeatDiv{ position: absolute; bottom: 10px; left: 10px;}
.thresholdDiv{ position: absolute; bottom: 10px; right: 10px; width: 150px;}
.autoRepeatArea{ margin: 10px 5px; font-size: 16px; font-family: VT323; color: #008000; background-color: #000d00; border: 1px solid #008000; border-radius: 5px; padding: 5px 10px; width: 560px; height: 50px; position: absolute; top: 265px; left: 0px;}
.autoRepeatForm{ width: 350px; position: absolute; right: 0px; bottom: 0px;}12345678910111213141516171819202122232425262728293031323334353637383940414243444546
// default input assignmentsvar inputAssignments = { shiftLeft: ['left'], shiftRight: ['right'], softDrop: ['down'], rotateLeft: ['z'], rotateRight: ['x', 'up'], swap: ['shift', 'c'], hardDrop: ['space']};
var autoRepeatConfig = 50;var thresholdConfig = 200;
function loadGameControls() { var cookies = ['rotateLeft', 'rotateRight', 'shiftLeft', 'shiftRight', 'softDrop', 'hardDrop', 'swap'], i, curVal; // if custom controls need to be loaded if (readCookie('customControls') === 'TRUE') { // for each input cookie for (i = 0; i < cookies.length; i += 1) { // print the controls to the table curVal = readCookie(cookies[i]); document.getElementById(cookies[i]).innerHTML = curVal; // pass the controls into the config object inputAssignments[cookies[i]] = [curVal.toLowerCase()]; } }
var autoRepeat = readCookie('autoRepeat'); if (autoRepeat !== null) { autoRepeatConfig = parseInt(autoRepeat); } var threshold = readCookie('threshold'); if (threshold != null) { thresholdConfig = parseInt(threshold); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869var availKeys = [ "backspace", "tab", "enter", "shift", "ctrl", "alt", "space", "pageup", "pagedown", "end", "home", "left", "up", "right", "down", "insert", "delete", "multiply", "add", "subtract", "decimalpoint", "divide", "numlock", "scrollock", "semicolon", "equalsign", "comma", "dash", "period", "forwardslash", "openbracket", "backslash", "closebracket", "singlequote", "numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9", "0","1","2","3","4","5","6","7","8","9", "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
var inputPolling = false;
function InputMonitor() { // give the program a global reference to me this.setup = function(){ jaws.preventDefaultKeys(availKeys); }; // do nothing this.draw = function(){};
// polls the keys if appropriate this.update = function() { var i, pressed; for (i = 0; i < availKeys.length && inputPolling; i += 1) { pressed = jaws.pressed(availKeys[i]); if (pressed) { reportKeyPressed(availKeys[i]); inputPolling = false; break; } } }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520/* * * Jaws - a HTML5 canvas/javascript 2D game development framework * * Homepage: http://jawsjs.com/ * Works with: Chrome 6.0+, Firefox 3.6+, 4+, IE 9+ * License: LGPL - http://www.gnu.org/licenses/lgpl.html * * Formating guide: * * jaws.oneFunction() * jaws.one_variable = 1 * new jaws.OneConstructor * * Jaws uses the "module pattern" and exposes itself through the global "jaws". * It should play nice with all other JS libs. * * Have fun! * * ippa. * */
var jaws = (function(jaws) {
var titlevar log_tag
jaws.title = function(value) { if(value) { return (title.innerHTML = value) } return title.innerHTML}
/* * Unpacks Jaws core-constructors into the global namespace * After calling unpack you can use: * "Sprite()" instead of "jaws.Sprite()" * "Animation()" instead of "jaws.Animation()" * .. and so on. * */jaws.unpack = function() { var make_global = ["Sprite", "SpriteList", "Animation", "Viewport", "SpriteSheet", "Parallax", "TileMap", "Rect", "pressed"]
make_global.forEach( function(item, array, total) { if(window[item]) { jaws.log(item + "already exists in global namespace") } else { window[item] = jaws[item] } });}
/* * Logger, adds text to previously found or created <div id="jaws-log"> */jaws.log = function(msg, add) { if(log_tag) { msg += "<br />" if(add) { log_tag.innerHTML = log_tag.innerHTML.toString() + msg } else { log_tag.innerHTML = msg } }}
/* * init() * * Initializes / creates: * - jaws.canvas / jaws.context / jaws.dom (our drawable gamearea) * - jaws.width / jaws.height (width/height of drawable gamearea) * - jaws.url_parameters (hash of key/values of all parameters in current url) * - title / log_tag (used internally by jaws) * * */jaws.init = function(options) { /* Find <title> tag */ title = document.getElementsByTagName('title')[0] jaws.url_parameters = getUrlParameters()
/* * If debug=1 parameter is present in the URL, let's either find <div id="jaws-log"> or create the tag. * jaws.log(message) will use this div for debug/info output to the gamer or developer * */ log_tag = document.getElementById('jaws-log') if(jaws.url_parameters["debug"]) { if(!log_tag) { log_tag = document.createElement("div") log_tag.style.cssText = "overflow: auto; color: #aaaaaa; width: 300px; height: 150px; margin: 40px auto 0px auto; padding: 5px; border: #444444 1px solid; clear: both; font: 10px verdana; text-align: left;" document.body.appendChild(log_tag) } }
jaws.canvas = document.getElementsByTagName('canvas')[0] if(jaws.canvas) { jaws.context = jaws.canvas.getContext('2d'); } else { jaws.dom = document.getElementById("canvas") jaws.dom.style.position = "relative" // This is needed to have sprites with position = "absolute" stay within the canvas } jaws.width = jaws.canvas ? jaws.canvas.width : jaws.dom.offsetWidth jaws.height = jaws.canvas ? jaws.canvas.height : jaws.dom.offsetHeigh}
/* ** Find the <canvas> so following draw-operations can use it.* If the developer didn't provide a <canvas> in his HTML, let's create one.**/function findOrCreateCanvas() { jaws.canvas = document.getElementsByTagName('canvas')[0] if(!jaws.canvas) { jaws.canvas = document.createElement("canvas") jaws.canvas.width = 500 jaws.canvas.height = 300 document.body.appendChild(jaws.canvas) jaws.log("creating canvas", true) } else { jaws.log("found canvas", true) } jaws.context = jaws.canvas.getContext('2d');}
/* * Quick and easy startup of a jaws gameloop. Can be called in different ways: * * jaws.start(Game) // Start game state Game() with default options * jaws.start(Game, {fps: 30}) // Start game state Geme() with options, in this case jaws will un Game with FPS 30 * jaws.start(window) // * */jaws.start = function(game_state, options) { var wanted_fps = (options && options.fps) || 60
jaws.init() jaws.log("setupInput()", true) jaws.setupInput()
/* Callback for when one single assets has been loaded */ function assetLoaded(src, percent_done) { jaws.log( percent_done + "%: " + src, true) }
/* Callback for when an asset can't be loaded*/ function assetError(src) { jaws.log( "Error loading: " + src) }
/* Callback for when all assets are loaded */ function assetsLoaded() { jaws.log("all assets loaded", true) // This makes both jaws.start() and jaws.start(MenuState) possible // Run game state constructor (new) after all assets are loaded if( game_state && jaws.isFunction(game_state) ) { game_state = new game_state } if(!game_state) { game_state = window }
jaws.gameloop = new jaws.GameLoop(game_state.setup, game_state.update, game_state.draw, wanted_fps) jaws.game_state = game_state jaws.gameloop.start() }
jaws.log("assets.loadAll()", true) if(jaws.assets.length() > 0) { jaws.assets.loadAll({onload:assetLoaded, onerror:assetError, onfinish:assetsLoaded}) } else { assetsLoaded() } }
/* * Switch to a new active game state * Save previous game state in jaws.previous_game_state */jaws.switchGameState = function(game_state) { jaws.gameloop.stop() jaws.clearKeyCallbacks() // clear out all keyboard callbacks if(jaws.isFunction(game_state)) { game_state = new game_state } jaws.previous_game_state = jaws.game_state jaws.game_state = game_state jaws.gameloop = new jaws.GameLoop(game_state.setup, game_state.update, game_state.draw, jaws.gameloop.fps) jaws.gameloop.start()}
/* Always return obj as an array. forceArray(1) -> [1], forceArray([1,2]) -> [1,2] */jaws.forceArray = function(obj) { return Array.isArray(obj) ? obj : [obj]}
/* Clears canvas through context.clearRect() */jaws.clear = function() { jaws.context.clearRect(0,0,jaws.width,jaws.height)}
/* returns true if obj is an Image */jaws.isImage = function(obj) { return Object.prototype.toString.call(obj) === "[object HTMLImageElement]" }
/* returns true of obj is a Canvas-element */jaws.isCanvas = function(obj) { return Object.prototype.toString.call(obj) === "[object HTMLCanvasElement]" }
/* returns true of obj is either an Image or a Canvas-element */jaws.isDrawable = function(obj) { return jaws.isImage(obj) || jaws.isCanvas(obj) }
/* returns true if obj is a String */jaws.isString = function(obj) { return (typeof obj == 'string') }
/* returns true if obj is an Array */jaws.isArray = function(obj) { return !(obj.constructor.toString().indexOf("Array") == -1) }
/* returns true of obj is a Function */jaws.isFunction = function(obj) { return (Object.prototype.toString.call(obj) === "[object Function]") }
/* * Return a hash of url-parameters and their values * * http://test.com/?debug=1&foo=bar -> [debug: 1, foo: bar] */function getUrlParameters() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars;}
return jaws;})(jaws || {});
var jaws = (function(jaws) {
var pressed_keys = {} var keycode_to_string = [] var on_keydown_callbacks = [] var on_keyup_callbacks = [] /* * Map all javascript keycodes to easy-to-remember letters/words */jaws.setupInput = function() { var k = [] k[8] = "backspace" k[9] = "tab" k[13] = "enter" k[16] = "shift" k[17] = "ctrl" k[18] = "alt" k[19] = "pause" k[20] = "capslock" k[27] = "esc" k[32] = "space" k[33] = "pageup" k[34] = "pagedown" k[35] = "end" k[36] = "home" k[37] = "left" k[38] = "up" k[39] = "right" k[40] = "down" k[45] = "insert" k[46] = "delete" k[91] = "leftwindowkey" k[92] = "rightwindowkey" k[93] = "selectkey" k[106] = "multiply" k[107] = "add" k[109] = "subtract" k[110] = "decimalpoint" k[111] = "divide" k[144] = "numlock" k[145] = "scrollock" k[186] = "semicolon" k[187] = "equalsign" k[188] = "comma" k[189] = "dash" k[190] = "period" k[191] = "forwardslash" k[192] = "graveaccent" k[219] = "openbracket" k[220] = "backslash" k[221] = "closebracket" k[222] = "singlequote"
var numpadkeys = ["numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9"] var fkeys = ["f1","f2","f3","f4","f5","f6","f7","f8","f9"] var numbers = ["0","1","2","3","4","5","6","7","8","9"] var letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] for(var i = 0; numbers[i]; i++) { k[48+i] = numbers[i] } for(var i = 0; letters[i]; i++) { k[65+i] = letters[i] } for(var i = 0; numpadkeys[i]; i++) { k[96+i] = numpadkeys[i] } for(var i = 0; fkeys[i]; i++) { k[112+i] = fkeys[i] } keycode_to_string = k
window.onkeydown = function(e) { handleKeyDown(e) } window.onkeyup = function(e) { handleKeyUp(e) } window.onkeypress = function(e) {};}
// handle event "onkeydown" by remembering what key was pressedfunction handleKeyUp(e) { event = (e) ? e : window.event var human_name = keycode_to_string[event.keyCode] pressed_keys[human_name] = false if(on_keyup_callbacks[human_name]) { on_keyup_callbacks[human_name]() e.preventDefault() } if(prevent_default_keys[human_name]) { e.preventDefault() }}
// handle event "onkeydown" by remembering what key was un-pressedfunction handleKeyDown(e) { event = (e) ? e : window.event var human_name = keycode_to_string[event.keyCode] pressed_keys[human_name] = true if(on_keydown_callbacks[human_name]) { on_keydown_callbacks[human_name]() e.preventDefault() } if(prevent_default_keys[human_name]) { e.preventDefault() }
// jaws.log(event.type + " - " + event.keyCode + " " + keycode_to_string[event.keyCode]); // e.preventDefault();}
var prevent_default_keys = []jaws.preventDefaultKeys = function(array_of_strings) { array_of_strings.forEach( function(item, index) { prevent_default_keys[item] = true });}
/* * helper to check if a given key currently is pressed. returns true or false. */jaws.pressed = function(string) { return pressed_keys[string]}
jaws.on_keydown = function(key, callback) { if(jaws.isArray(key)) { for(var i=0; key[i]; i++) { on_keydown_callbacks[key[i]] = callback } } else { on_keydown_callbacks[key] = callback }}
jaws.on_keyup = function(key, callback) { if(jaws.isArray(key)) { for(var i=0; key[i]; i++) { on_keyup_callbacks[key[i]] = callback } } else { on_keyup_callbacks[key] = callback }}
/* Clean up all callbacks set by on_keydown / on_keyup */jaws.clearKeyCallbacks = function() { on_keyup_callbacks = [] on_keydown_callbacks = []}
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * jaws.Assets() * * Mass load / processing of assets (images, sound, video, json) * */jaws.Assets = function() { this.loaded = [] // Hash of all URLs that's been loaded this.loading = [] // Hash of all URLs currently loading this.src_list = [] // Hash of all unloaded URLs that loadAll() will try to load this.data = [] // Hash of loaded raw asset data, URLs are keys
this.image_to_canvas = true this.fuchia_to_transparent = true this.root = ""
this.file_type = {} this.file_type["json"] = "json" this.file_type["wav"] = "audio" this.file_type["mp3"] = "audio" this.file_type["ogg"] = "audio" this.file_type["png"] = "image" this.file_type["jpg"] = "image" this.file_type["jpeg"] = "image" this.file_type["gif"] = "image" this.file_type["bmp"] = "image" this.file_type["tiff"] = "image" var that = this
this.length = function() { return this.src_list.length }
/* * Get one or many resources * * @param String or Array of strings * @returns The raw resource or an array of resources * */ this.get = function(src) { if(jaws.isArray(src)) { return src.map( function(i) { return that.data[i] } ) } else { if(this.loaded[src]) { return this.data[src] } else { jaws.log("No such asset: " + src) } } } this.isLoading = function(src) { return this.loading[src] } this.isLoaded = function(src) { return this.loaded[src] } this.getPostfix = function(src) { postfix_regexp = /\.([a-zA-Z]+)/; return postfix_regexp.exec(src)[1] }
this.getType = function(src) { var postfix = this.getPostfix(src) return (this.file_type[postfix] ? this.file_type[postfix] : postfix) } /* Add array of paths or single path to asset-list. Later load with loadAll() */ this.add = function(src) { if(jaws.isArray(src)) { for(var i=0; src[i]; i++) { this.add(src[i]) } } else { src = this.root + src; this.src_list.push(src) } return this } /* Load all assets */ this.loadAll = function(options) { this.load_count = 0 this.error_count = 0
/* With these 3 callbacks you can display progress and act when all assets are loaded */ this.onload = options.onload this.onerror = options.onerror this.onfinish = options.onfinish
for(i=0; this.src_list[i]; i++) { this.load(this.src_list[i]) } }
/* Calls onload right away if asset is available since before, otherwise try to load it */ this.getOrLoad = function(src, onload, onerror) { if(this.data[src]) { onload() } else { this.load(src, onload, onerror) } }
/* Load one asset-object, i.e: {src: "foo.png"} */ this.load = function(src, onload, onerror) { var asset = {} asset.src = src asset.onload = onload asset.onerror = onerror this.loading[src] = true
switch(this.getType(asset.src)) { case "image": var src = asset.src + "?" + parseInt(Math.random()*10000000) asset.image = new Image() asset.image.asset = asset // enables us to access asset in the callback asset.image.onload = this.assetLoaded asset.image.onerror = this.assetError asset.image.src = src break; case "audio": var src = asset.src + "?" + parseInt(Math.random()*10000000) asset.audio = new Audio(src) asset.audio.asset = asset // enables us access asset in the callback this.data[asset.src] = asset.audio asset.audio.addEventListener("canplay", this.assetLoaded, false); asset.audio.addEventListener("error", this.assetError, false); asset.audio.load() break; default: var src = asset.src + "?" + parseInt(Math.random()*10000000) var req = new XMLHttpRequest() req.asset = asset // enables us access asset in the callback req.onreadystatechange = this.assetLoaded req.open('GET', src, true) req.send(null) break; } }
/* * Callback for all asset-loading. * 1) Parse data depending on filetype. Images are (optionally) converted to canvas-objects. json are parsed into native objects and so on. * 2) Save processed data in internal list for easy fetching with assets.get(src) later on * 3) Call callbacks if defined */ this.assetLoaded = function(e) { var asset = this.asset var src = asset.src var filetype = that.getType(asset.src) // Keep loading and loaded hash up to date that.loaded[src] = true that.loading[src] = false
// Process data depending differently on postfix if(filetype == "json") { if (this.readyState != 4) { return } that.data[asset.src] = JSON.parse(this.responseText) } else if(filetype == "image") { var new_image = that.image_to_canvas ? imageToCanvas(asset.image) : asset.image if(that.fuchia_to_transparent && that.getPostfix(asset.src) == "bmp") { new_image = fuchiaToTransparent(new_image) } that.data[asset.src] = new_image } else if(filetype == "audio") { asset.audio.removeEventListener("canplay", that.assetLoaded, false); that.data[asset.src] = asset.audio } that.load_count++ if(asset.onload) { asset.onload() } // single asset load()-callback that.processCallbacks(asset) }
this.assetError = function(e) { var asset = this.asset that.error_count++ if(asset.onerror) { asset.onerror(asset) } that.processCallbacks(asset) }
this.processCallbacks = function(asset) { var percent = parseInt( (that.load_count+that.error_count) / that.src_list.length * 100) if(that.onload) { that.onload(asset.src, percent) } // loadAll() - single asset has loaded callback // When loadAll() is 100%, call onfinish() and kill callbacks (reset with next loadAll()-call) if(percent==100) { if(that.onfinish) { that.onfinish() } that.onload = null that.onerror = null that.onfinish = null } }}
/* * Takes an image, returns a canvas. * Benchmarks has proven canvas to be faster to work with then images. * Returns: a canvas */function imageToCanvas(image) { var canvas = document.createElement("canvas") canvas.src = image.src // Make canvas look more like an image canvas.width = image.width canvas.height = image.height
var context = canvas.getContext("2d") context.drawImage(image, 0, 0, image.width, image.height) return canvas}
/* * Make Fuchia (0xFF00FF) transparent * This is the de-facto standard way to do transparency in BMPs * Returns: a canvas */function fuchiaToTransparent(image) { canvas = jaws.isImage(image) ? imageToCanvas(image) : image var context = canvas.getContext("2d") var img_data = context.getImageData(0,0,canvas.width,canvas.height) var pixels = img_data.data for(var i = 0; i < pixels.length; i += 4) { if(pixels[i]==255 && pixels[i+1]==0 && pixels[i+2]==255) { // Color: Fuchia pixels[i+3] = 0 // Set total see-through transparency } } context.putImageData(img_data,0,0); return canvas}
/* Scale image by factor and keep jaggy retro-borders */function retroScale(image, factor) { canvas = jaws.isImage(image) ? imageToCanvas(image) : image var context = canvas.getContext("2d") var img_data = context.getImageData(0,0,canvas.width,canvas.height) var pixels = img_data.data
var canvas2 = document.createElement("canvas") canvas2.width = image.width * factor canvas2.height = image.height * factor var context2 = canvas.getContext("2d") var img_data2 = context2.getImageData(0,0,canvas2.width,canvas2.height) var pixels2 = img_data2.data
for (var x = 0; x < canvas.width * factor; x++) { for (var y = 0; y < canvas.height * factor; y++) { pixels2[x*y] = pixels[x*y / factor] pixels2[x*y+1] = pixels[x*y+1 / factor] pixels2[x*y+2] = pixels[x*y+2 / factor] pixels2[x*y+3] = pixels[x*y+3 / factor] } }
context2.putImageData(img_data2,0,0); return canvas2}
jaws.assets = new jaws.Assets()
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * * GameLoop * * function draw() { * ... your stuff executed every 30 FPS ... * } * * gameloop = jaws.GameLoop(setup, update, draw, 30) * gameloop.start() * * gameloop.start() starts a 2-step process, where first all assets are loaded. * Then the real gameloop is started with the userspecified FPS. * * If using the shorter jaws.init() a GameLoop will automatically be created and started for you. * */jaws.GameLoop = function(setup, update, draw, wanted_fps) { this.ticks = 0 this.tick_duration = 0 this.fps = 0 var update_id var paused = false var that = this var mean_value = new MeanValue(20) // let's have a smooth, non-jittery FPS-value
this.start = function() { jaws.log("gameloop start", true) this.current_tick = (new Date()).getTime(); this.last_tick = (new Date()).getTime(); if(setup) { setup() } update_id = setInterval(this.loop, 1000 / wanted_fps); jaws.log("gameloop loop", true) } this.loop = function() { that.current_tick = (new Date()).getTime(); that.tick_duration = that.current_tick - that.last_tick //that.fps = parseInt(1000 / that.tick_duration) that.fps = mean_value.add(1000/that.tick_duration).get()
if(!paused) { if(update) { update() } if(draw) { draw() } that.ticks++ }
that.last_tick = that.current_tick; } this.pause = function() { paused = true } this.unpause = function() { paused = false }
this.stop = function() { if(update_id) { clearInterval(update_id); } }}
function MeanValue(size) { this.size = size this.values = new Array(this.size) this.value
this.add = function(value) { if(this.values.length > this.size) { // is values filled? this.values.splice(0,1) this.value = 0 for(var i=0; this.values[i]; i++) { this.value += this.values[i] } this.value = this.value / this.size } this.values.push(value) return this }
this.get = function() { return parseInt(this.value) }
}
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * A bread and butter Rect() - useful for basic collision detection */jaws.Rect = function(x,y,width,height) { this.x = x this.y = y this.width = width this.height = height this.right = x + width this.bottom = y + height}
jaws.Rect.prototype.getPosition = function() { return [this.x, this.y]}
jaws.Rect.prototype.move = function(x,y) { this.x += x this.y += y this.right += x this.bottom += y}
jaws.Rect.prototype.moveTo = function(x,y) { this.x = x this.y = y this.right = this.x + this.width this.bottom = this.y + this.height return this}
jaws.Rect.prototype.resize = function(width,height) { this.width += width this.height += height this.right = this.x + this.width this.bottom = this.y + this.height return this}
jaws.Rect.prototype.resizeTo = function(width,height) { this.width = width this.height = height this.right = this.x + this.width this.bottom = this.y + this.height return this}
// Draw a red rectangle, useful for debugjaws.Rect.prototype.draw = function() { jaws.context.strokeStyle = "red" jaws.context.strokeRect(this.x, this.y, this.width, this.height) return this}
// Returns true if point at x, y lies within calling rectjaws.Rect.prototype.collidePoint = function(x, y) { return (x >= this.x && x <= this.right && y >= this.y && y <= this.bottom)}
// Returns true if calling rect overlaps with given rect in any wayjaws.Rect.prototype.collideRect = function(rect) { return ((this.x >= rect.x && this.x <= rect.right) || (rect.x >= this.x && rect.x <= this.right)) && ((this.y >= rect.y && this.y <= rect.bottom) || (rect.y >= this.y && rect.y <= this.bottom))}
/*// Possible future functionsjaws.Rect.prototype.collideRightSide = function(rect) { return(this.right >= rect.x && this.x < rect.x) }jaws.Rect.prototype.collideLeftSide = function(rect) { return(this.x > rect.x && this.x <= rect.right) }jaws.Rect.prototype.collideTopSide = function(rect) { return(this.y >= rect.y && this.y <= rect.bottom) }jaws.Rect.prototype.collideBottomSide = function(rect) { return(this.bottom >= rect.y && this.y < rect.y) }*/
jaws.Rect.prototype.toString = function() { return "[Rect " + this.x + ", " + this.y + ", " + this.width + ", " + this.height + "]" }
return jaws;})(jaws || {});
// Support CommonJS require()if(typeof module !== "undefined" && ('exports' in module)) { module.exports = jaws.Rect }
/* * * When we wan't to move something visible around on the screen :). * * */var jaws = (function(jaws) {
jaws.Sprite = function(options) { this.options = options this.set(options) this.context = options.context || jaws.context if(!this.context) { this.createDiv() } // No canvas context? Switch to DOM-based spritemode}
/* Call setters from JSON object. Used to parse options. */jaws.Sprite.prototype.set = function(options) { this.scale_factor_x = this.scale_factor_y = (options.scale || 1) if(!options.anchor_x == undefined) {this.anchor_x = options.anchor_x} if(!options.anchor_y == undefined) {this.anchor_y = options.anchor_y} this.x = options.x || 0 this.y = options.y || 0 this.alpha = options.alpha || 1 this.angle = options.angle || 0 this.flipped = options.flipped || false this.anchor(options.anchor || "top_left") options.image && this.setImage(options.image) this.cacheOffsets() return this}
/*//// Chainable setters under consideration://jaws.Sprite.prototype.setFlipped = function(value) { this.flipped = value; return this }jaws.Sprite.prototype.setAlpha = function(value) { this.alpha = value; return this }jaws.Sprite.prototype.setAnchorX = function(value) { this.anchor_x = value; this.cacheOffsets(); return this }jaws.Sprite.prototype.setAnchorY = function(value) { this.anchor_y = value; this.cacheOffsets(); return this }jaws.Sprite.prototype.setAngle = function(value) { this.angle = value; return this }jaws.Sprite.prototype.setScaleFactor = function(value) { this.scale_factor_x = this.scale_factor_y = value; this.cacheOffsets(); return this }jaws.Sprite.prototype.setScaleFactorX = function(value) { this.scale_factor_x = value; this.cacheOffsets(); return this }jaws.Sprite.prototype.setScaleFactorY = function(value) { this.scale_factor_y = value; this.cacheOffsets(); return this }jaws.Sprite.prototype.moveX = function(x) { this.x += x; return this }jaws.Sprite.prototype.moveXTo = function(x) { this.x = x; return this }jaws.Sprite.prototype.moveY = function(y) { this.y += y; return this }jaws.Sprite.prototype.moveYTo = function(y) { this.y = y; return this }jaws.Sprite.prototype.scaleWidthTo = function(value) { this.scale_factor_x = value; return this.cacheOffsets() }jaws.Sprite.prototype.scaleHeightTo = function(value) { this.scale_factor_y = value; return this.cachOfffsets() }*/
/* Sprite modifiers. Modifies 1 or more properties and returns this for chainability. */jaws.Sprite.prototype.setImage = function(value) { var that = this
// An image, great, set this.image and return if(jaws.isDrawable(value)) { this.image = value return this.cacheOffsets() } // Not an image, therefore an asset string, i.e. "ship.bmp" else { // Assets already loaded? Set this.image if(jaws.assets.isLoaded(value)) { this.image = jaws.assets.get(value); this.cacheOffsets(); }
// Not loaded? Load it with callback to set image. else { jaws.assets.load(value, function() { that.image = jaws.assets.get(value); that.cacheOffsets(); }) } } return this}jaws.Sprite.prototype.flip = function() { this.flipped = this.flipped ? false : true; return this }jaws.Sprite.prototype.flipTo = function(value) { this.flipped = value; return this }jaws.Sprite.prototype.rotate = function(value) { this.angle += value; return this }jaws.Sprite.prototype.rotateTo = function(value) { this.angle = value; return this }jaws.Sprite.prototype.moveTo = function(x,y) { this.x = x; this.y = y; return this }jaws.Sprite.prototype.move = function(x,y) { if(x) this.x += x; if(y) this.y += y; return this }jaws.Sprite.prototype.scale = function(value) { this.scale_factor_x *= value; this.scale_factor_y *= value; return this.cacheOffsets() }jaws.Sprite.prototype.scaleTo = function(value) { this.scale_factor_x = this.scale_factor_y = value; return this.cacheOffsets() }jaws.Sprite.prototype.scaleWidth = function(value) { this.scale_factor_x *= value; return this.cacheOffsets() }jaws.Sprite.prototype.scaleHeight = function(value) { this.scale_factor_y *= value; return this.cacheOffsets() }jaws.Sprite.prototype.setX = function(value) { this.x = value; return this }jaws.Sprite.prototype.setY = function(value) { this.y = value; return this }jaws.Sprite.prototype.setWidth = function(value) { this.scale_factor_x = value/this.image.width; return this.cacheOffsets() }jaws.Sprite.prototype.setHeight = function(value) { this.scale_factor_y = value/this.image.height; return this.cacheOffsets() }jaws.Sprite.prototype.resize = function(width, height) { this.scale_factor_x = (this.width + width) / this.image.width this.scale_factor_y = (this.height + height) / this.image.height return this.cacheOffsets()}jaws.Sprite.prototype.resizeTo = function(width, height) { this.scale_factor_x = width / this.image.width this.scale_factor_y = height / this.image.height return this.cacheOffsets()}
/** The sprites anchor could be describe as "the part of the sprite will be placed at x/y"* or "when rotating, what point of the of the sprite will it rotate round"** For example, a topdown shooter could use anchor("center") --> Place middle of the ship on x/y* .. and a sidescroller would probably use anchor("center_bottom") --> Place "feet" at x/y*/jaws.Sprite.prototype.anchor = function(value) { var anchors = { top_left: [0,0], left_top: [0,0], center_left: [0,0.5], left_center: [0,0.5], bottom_left: [0,1], left_bottom: [0,1], top_center: [0.5,0], center_top: [0.5,0], center_center: [0.5,0.5], center: [0.5,0.5], bottom_center: [0.5,1], center_bottom: [0.5,1], top_right: [1,0], right_top: [1,0], center_right: [1,0.5], right_center: [1,0.5], bottom_right: [1,1], right_bottom: [1,1] }
if(a = anchors[value]) { this.anchor_x = a[0] this.anchor_y = a[1] if(this.image) this.cacheOffsets(); } return this}
jaws.Sprite.prototype.cacheOffsets = function() { if(!this.image) { return } this.width = this.image.width * this.scale_factor_x this.height = this.image.height * this.scale_factor_y this.left_offset = this.width * this.anchor_x this.top_offset = this.height * this.anchor_y this.right_offset = this.width * (1.0 - this.anchor_x) this.bottom_offset = this.height * (1.0 - this.anchor_y)
if(this.cached_rect) this.cached_rect.resizeTo(this.width, this.height); return this}
/* Saves a Rect() perfectly surrouning our sprite in this.cached_rect and returns it */jaws.Sprite.prototype.rect = function() { if(!this.cached_rect) this.cached_rect = new jaws.Rect(this.x, this.top, this.width, this.height) this.cached_rect.moveTo(this.x - this.left_offset, this.y - this.top_offset) return this.cached_rect}
/* Make this sprite a DOM-based <div> sprite */jaws.Sprite.prototype.createDiv = function() { this.div = document.createElement("div") this.div.style.position = "absolute" if(this.image) { this.div.style.width = this.image.width + "px" this.div.style.height = this.image.height + "px" this.div.style.backgroundImage = "url(" + this.image.src + ")" } if(jaws.dom) { jaws.dom.appendChild(this.div) } this.updateDiv()}
/* Update properties for DOM-based sprite */jaws.Sprite.prototype.updateDiv = function() { this.div.style.left = this.x + "px" this.div.style.top = this.y + "px"
var transform = "" transform += "rotate(" + this.angle + "deg) " if(this.flipped) { transform += "scale(-" + this.scale_factor_x + "," + this.scale_factor_y + ")"; } else { transform += "scale(" + this.scale_factor_x + "," + this.scale_factor_y + ")"; }
this.div.style.MozTransform = transform this.div.style.WebkitTransform = transform this.div.style.transform = transform return this}
// Draw the sprite on screen via its previously given contextjaws.Sprite.prototype.draw = function() { if(!this.image) { return this } if(jaws.dom) { return this.updateDiv() }
this.context.save() this.context.translate(this.x, this.y) if(this.angle!=0) { jaws.context.rotate(this.angle * Math.PI / 180) } this.flipped && this.context.scale(-1, 1) this.context.globalAlpha = this.alpha this.context.translate(-this.left_offset, -this.top_offset) // Needs to be separate from above translate call cause of flipped this.context.drawImage(this.image, 0, 0, this.width, this.height) this.context.restore() return this}
// Create a new canvas context, draw sprite on it and return. Use to get a raw canvas copy of the current sprite state.jaws.Sprite.prototype.asCanvasContext = function() { var canvas = document.createElement("canvas") canvas.width = this.width canvas.height = this.height
var context = canvas.getContext("2d") context.mozImageSmoothingEnabled = jaws.context.mozImageSmoothingEnabled
context.drawImage(this.image, 0, 0, this.width, this.height) return context}
jaws.Sprite.prototype.toString = function() { return "[Sprite " + this.x + ", " + this.y + "," + this.width + "," + this.height + "]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * * Constructor to manage your Sprites. * * Sprites (your bullets, aliens, enemies, players etc) will need to be * updated, draw, deleted. Often in various orders and based on different conditions. * * This is where SpriteList() comes in. * * var enemies = new SpriteList() * * for(i=0; i < 100; i++) { // create 100 enemies * enemies.push(new Sprite({image: "enemy.png", x: i, y: 200})) * } * enemies.draw() // calls draw() on all enemies * enemies.deleteIf(isOutsideCanvas) // deletes each item in enemies that returns true when isOutsideCanvas(item) is called * enemies.drawIf(isInsideViewport) // only call draw() on items that returns true when isInsideViewport is called with item as argument * */
jaws.SpriteList = function() {}jaws.SpriteList.prototype = new Array
jaws.SpriteList.prototype.remove = function(obj) { var index = this.indexOf(obj) if(index > -1) { this.splice(index, 1) }}
jaws.SpriteList.prototype.draw = function() { for(i=0; this[i]; i++) { this[i].draw() }}
jaws.SpriteList.prototype.drawIf = function(condition) { for(i=0; this[i]; i++) { if( condition(this[i]) ) { this[i].draw() } }}
jaws.SpriteList.prototype.update = function() { for(i=0; this[i]; i++) { this[i].update() }}
jaws.SpriteList.prototype.updateIf = function(condition) { for(i=0; this[i]; i++) { if( condition(this[i]) ) { this[i].update() } }}
jaws.SpriteList.prototype.deleteIf = function(condition) { for(var i=0; this[i]; i++) { if( condition(this[i]) ) { this.splice(i,1) } }}jaws.SpriteList.prototype.toString = function() { return "[SpriteList " + this.length + " sprites]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* Cut out a rectangular piece of a an image, returns as canvas-element */function cutImage(image, x, y, width, height) { var cut = document.createElement("canvas") cut.width = width cut.height = height var ctx = cut.getContext("2d") ctx.drawImage(image, x, y, width, height, 0, 0, cut.width, cut.height) return cut};
/* Cut up into frame_size pieces and put them in frames[] */jaws.SpriteSheet = function(options) { this.image = jaws.isDrawable(options.image) ? options.image : jaws.assets.data[options.image] this.orientation = options.orientation || "right" this.frame_size = options.frame_size || [32,32] this.frames = []
var index = 0 for(var x=0; x < this.image.width; x += this.frame_size[0]) { for(var y=0; y < this.image.height; y += this.frame_size[1]) { this.frames.push( cutImage(this.image, x, y, this.frame_size[0], this.frame_size[1]) ) } }}
jaws.SpriteSheet.prototype.toString = function() { return "[SpriteSheet " + this.frames.length + " frames]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
jaws.Parallax = function(options) { this.scale = options.scale || 1 this.repeat_x = options.repeat_x this.repeat_y = options.repeat_y this.camera_x = options.camera_x || 0 this.camera_y = options.camera_y || 0 this.layers = []}
jaws.Parallax.prototype.draw = function(options) { var layer, save_x, save_y;
for(var i=0; i < this.layers.length; i++) { layer = this.layers[i] save_x = layer.x save_y = layer.y
layer.x = -(this.camera_x / layer.damping) layer.y = -(this.camera_y / layer.damping)
while(this.repeat_x && layer.x > 0) { layer.x -= layer.width } while(this.repeat_y && layer.y > 0) { layer.y -= layer.width }
while(this.repeat_x && layer.x < jaws.width) { while(this.repeat_y && layer.y < jaws.height) { layer.draw() layer.y += layer.height } layer.y = save_y layer.draw() layer.x += (layer.width-1) // -1 to compensate for glitches in repeating tiles } while(layer.repeat_y && !layer.repeat_x && layer.y < jaws.height) { layer.draw() layer.y += layer.height } layer.x = save_x }}jaws.Parallax.prototype.addLayer = function(options) { var layer = new jaws.ParallaxLayer(options) layer.scale(this.scale) this.layers.push(layer)}jaws.Parallax.prototype.toString = function() { return "[Parallax " + this.x + ", " + this.y + ". " + this.layers.length + " layers]" }
jaws.ParallaxLayer = function(options) { this.damping = options.damping || 0 jaws.Sprite.call(this, options)}jaws.ParallaxLayer.prototype = jaws.Sprite.prototypejaws.Parallax.prototype.toString = function() { return "[ParallaxLayer " + this.x + ", " + this.y + "]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * * Animation() * * Manages animation with a given list of frames and durations * Takes a object as argument: * * loop: true|false - restart animation when end is reached * bounce: true|false - rewind the animation frame by frame when end is reached * index: int - start on this frame * frames array - array of image/canvas items * frame_duration int - how long should each frame be displayed * */jaws.Animation = function(options) { this.options = options this.frames = options.frames || [] this.frame_duration = options.frame_duration || 100 // default: 100ms between each frameswitch this.index = options.index || 0 // default: start with the very first frame this.loop = options.loop || 1 this.bounce = options.bounce || 0 this.frame_direction = 1
if(options.sprite_sheet) { var image = (jaws.isDrawable(options.sprite_sheet) ? options.sprite_sheet : jaws.assets.get(options.sprite_sheet)) var sprite_sheet = new jaws.SpriteSheet({image: image, frame_size: options.frame_size}) this.frames = sprite_sheet.frames }
/* Initializing timer-stuff */ this.current_tick = (new Date()).getTime(); this.last_tick = (new Date()).getTime(); this.sum_tick = 0}
// Propells the animation forward by counting milliseconds and changing this.index accordingly// Supports looping and bouncing animations.jaws.Animation.prototype.update = function() { this.current_tick = (new Date()).getTime(); this.sum_tick += (this.current_tick - this.last_tick); this.last_tick = this.current_tick; if(this.sum_tick > this.frame_duration) { this.index += this.frame_direction this.sum_tick = 0 } if( (this.index >= this.frames.length) || (this.index <= 0) ) { if(this.bounce) { this.frame_direction = -this.frame_direction this.index += this.frame_direction*2 } else if(this.loop) { this.index = 0 } } return this}
// Like array.slice but returns a new Animation-object with a subset of the framesjaws.Animation.prototype.slice = function(start, stop) { var o = {} o.frame_duration = this.frame_duration o.loop = this.loop o.bounce = this.bounce o.frame_direction = this.frame_direction o.frames = this.frames.slice().slice(start, stop) return new jaws.Animation(o)};
// Moves animation forward by calling update() and then return the current framejaws.Animation.prototype.next = function() { this.update() return this.frames[this.index]};
// returns the current framejaws.Animation.prototype.currentFrame = function() { return this.frames[this.index]};
jaws.Animation.prototype.toString = function() { return "[Animation, " + this.frames.length + " frames]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * * Viewport() is a window (a Rect) into a bigger canvas/image * * It won't every go "outside" that image. * It comes with convenience methods as: * * viewport.centerAround(player) which will do just what you think. (player needs to have properties x and y) * * */jaws.Viewport = function(options) { this.options = options this.context = options.context || jaws.context this.width = options.width || jaws.width this.height = options.height || jaws.height this.max_x = options.max_x || jaws.width this.max_y = options.max_y || jaws.height this.verifyPosition = function() { var max = this.max_x - this.width if(this.x < 0) { this.x = 0 } if(this.x > max) { this.x = max }
var max = this.max_y - this.height if(this.y < 0) { this.y = 0 } if(this.y > max) { this.y = max } }; this.move = function(x, y) { x && (this.x += x) y && (this.y += y) this.verifyPosition() }; this.moveTo = function(x, y) { if(!(x==undefined)) { this.x = x } if(!(y==undefined)) { this.y = y } this.verifyPosition() };
this.isOutside = function(item) { return(!this.isInside(item)) };
this.isInside = function(item) { return( item.x >= this.x && item.x <= (this.x + this.width) && item.y >= this.y && item.y <= (this.y + this.height) ) };
this.centerAround = function(item) { this.x = (item.x - this.width / 2) this.y = (item.y - this.height / 2) this.verifyPosition() };
this.apply = function(func) { this.context.save() this.context.translate(-this.x, -this.y) func() this.context.restore() }; this.moveTo(options.x||0, options.y||0)}
jaws.Viewport.prototype.toString = function() { return "[Viewport " + this.x + ", " + this.y + "," + this.width + "," + this.height + "]" }
return jaws;})(jaws || {});
var jaws = (function(jaws) {
/* * TileMap - fast access to tiles * * var tile_map = new TileMap({size: [10, 10], cell_size: [16,16]}) * var sprite = new jaws.Sprite({x: 40, y: 40}) * var sprite2 = new jaws.Sprite({x: 41, y: 41}) * tile_map.push(sprite) * * tile_map.at(10,10) // [] * tile_map.at(40,40) // [sprite] * tile_map.cell(0,0) // [] * tile_map.cell(1,1) // [sprite] * */jaws.TileMap = function(options) { this.cell_size = options.cell_size || [32,32] this.size = options.size this.cells = new Array(this.size[0]) this.sortFunction = undefined
for(var col=0; col < this.size[0]; col++) { this.cells[col] = new Array(this.size[1]) for(var row=0; row < this.size[1]; row++) { this.cells[col][row] = [] // populate each cell with an empty array } }}
/* Clear all cells in tile map */jaws.TileMap.prototype.clear = function() { for(var col=0; col < this.size[0]; col++) { for(var row=0; row < this.size[1]; row++) { this.cells[col][row] = [] } }}
/* Sort arrays in each cell in tile map according to sorter-function (see Array.sort) */jaws.TileMap.prototype.sortCells = function(sortFunction) { for(var col=0; col < this.size[0]; col++) { for(var row=0; row < this.size[1]; row++) { this.cells[col][row].sort( sortFunction ) } }}
/* * Push obj (or array of objs) into our cell-grid. * * Tries to read obj.x and obj.y to calculate what cell to occopy */jaws.TileMap.prototype.push = function(obj) { if(obj.length) { for(var i=0; i < obj.length; i++) { this.push(obj[i]) } return obj } if(obj.rect) { return this.pushAsRect(obj, obj.rect()) } else { var col = parseInt(obj.x / this.cell_size[0]) var row = parseInt(obj.y / this.cell_size[1]) return this.pushToCell(col, row, obj) }
}jaws.TileMap.prototype.pushAsPoint = function(obj) { if(Array.isArray(obj)) { for(var i=0; i < obj.length; i++) { this.pushAsPoint(obj[i]) } return obj } else { var col = parseInt(obj.x / this.cell_size[0]) var row = parseInt(obj.y / this.cell_size[1]) return this.pushToCell(col, row, obj) }}
/* save 'obj' in cells touched by 'rect' */jaws.TileMap.prototype.pushAsRect = function(obj, rect) { var from_col = parseInt(rect.x / this.cell_size[0]) var to_col = parseInt((rect.right-1) / this.cell_size[0]) //jaws.log("rect.right: " + rect.right + " from/to col: " + from_col + " " + to_col, true)
for(var col = from_col; col <= to_col; col++) { var from_row = parseInt(rect.y / this.cell_size[1]) var to_row = parseInt((rect.bottom-1) / this.cell_size[1]) //jaws.log("rect.bottom " + rect.bottom + " from/to row: " + from_row + " " + to_row, true) for(var row = from_row; row <= to_row; row++) { // console.log("pushAtRect() col/row: " + col + "/" + row + " - " + this.cells[col][row]) this.pushToCell(col, row, obj) } } return obj}
/* * Push obj to a specific cell specified by col and row * If cell is already occupied we create an array and push to that */jaws.TileMap.prototype.pushToCell = function(col, row, obj) { this.cells[col][row].push(obj) if(this.sortFunction) this.cells[col][row].sort(this.sortFunction); return this}
//// READERS//
/* Get objects in cell that exists at coordinates x / y */jaws.TileMap.prototype.at = function(x, y) { var col = parseInt(x / this.cell_size[0]) var row = parseInt(y / this.cell_size[1]) // console.log("at() col/row: " + col + "/" + row) return this.cells[col][row]}
/* Returns occupants of all cells touched by 'rect' */jaws.TileMap.prototype.atRect = function(rect) { var objects = [] var items var from_col = parseInt(rect.x / this.cell_size[0]) var to_col = parseInt(rect.right / this.cell_size[0]) for(var col = from_col; col <= to_col; col++) { var from_row = parseInt(rect.y / this.cell_size[1]) var to_row = parseInt(rect.bottom / this.cell_size[1]) for(var row = from_row; row <= to_row; row++) { this.cells[col][row].forEach( function(item, total) { if(objects.indexOf(item) == -1) { objects.push(item) } }) } } return objects}
/* Returns all objects in tile map */jaws.TileMap.prototype.all = function() { var all = [] for(var col=0; col < this.size[0]; col++) { for(var row=0; row < this.size[1]; row++) { this.cells[col][row].forEach( function(element, total) { all.push(element) }); } } return all}
/* * Get objects in cell at col / row */jaws.TileMap.prototype.cell = function(col, row) { return this.cells[col][row]}
jaws.TileMap.prototype.toString = function() { return "[TileMap " + this.size[0] + " cols, " + this.size[1] + " rows]" }
return jaws;})(jaws || {});
// Support CommonJS require()if(typeof module !== "undefined" && ('exports' in module)) { module.exports = jaws.TileMap }filestorage/gd/aiwnios/aiwnios.jsAdded
filestorage/gd/aiwnios/index.htmlAdded+22
filestorage/gd/georgeandtheprinter/index.htmlAdded+26
filestorage/gd/half-life/browserfs.min.jsAdded
filestorage/gd/half-life/client.jsAdded
filestorage/gd/half-life/favicon.icoAdded
filestorage/gd/half-life/index.htmlAdded+697
filestorage/gd/half-life/menu.jsAdded
filestorage/gd/half-life/mods.jsAdded+27
filestorage/gd/half-life/server.jsAdded
filestorage/gd/half-life/xash.jsAdded
filestorage/gd/spicyfuse-runiestory/binjgb.jsAdded+21
filestorage/gd/spicyfuse-runiestory/index.htmlAdded+34
filestorage/gd/tetris/WallKicks.jsAdded+67
filestorage/gd/tetris/about.htmlAdded+68
filestorage/gd/tetris/controls.htmlAdded+129
filestorage/gd/tetris/controlsStyles.cssAdded+113
filestorage/gd/tetris/gameControls.jsAdded+46
filestorage/gd/tetris/input.jsAdded+69
filestorage/gd/tetris/jawsjs.jsAdded+1520