Add files using upload-large-folder tool
Browse filesFiles changed (30)
- filestorage/gd/13/cover.svgAdded
- filestorage/gd/13/index.htmlAdded+32
- filestorage/gd/adastra-17/index.htmlAdded+233
- filestorage/gd/adastra-17/index.html.symbolsAdded
- filestorage/gd/adastra-17/manifest.jsonAdded+1
- filestorage/gd/adastra-17/pwa_catalog.jsonAdded+1
- filestorage/gd/adastra-17/renpy-pre.jsAdded+983
- filestorage/gd/adastra-17/service-worker.jsAdded+92
- filestorage/gd/tetris/Background.jsAdded+59
- filestorage/gd/tetris/Block.jsAdded+111
- filestorage/gd/tetris/Button.jsAdded+13
- filestorage/gd/tetris/ControlGroup.jsAdded+372
- filestorage/gd/tetris/Game.jsAdded+301
- filestorage/gd/tetris/Game_Logic.jsAdded+209
- filestorage/gd/tetris/PreviewGroup.jsAdded+47
- filestorage/gd/tetris/README.mdAdded+15
- filestorage/gd/tetris/RandomBag.jsAdded+49
- filestorage/gd/tetris/ScoreTracker.jsAdded+213
- filestorage/gd/tetris/Shapes.jsAdded+94
- filestorage/gd/tetris/TtyBlock.jsAdded+84
- filestorage/gd/tetris/controls.jsAdded+202
- filestorage/gd/tetris/cookie.jsAdded+24
- filestorage/gd/tetris/highScores.htmlAdded+62
- filestorage/gd/tetris/highScores.jsAdded+39
- filestorage/gd/tetris/index.htmlAdded+43
- filestorage/gd/tetris/json-minified.jsAdded+4
- filestorage/gd/tetris/scoreScreen.htmlAdded+71
- filestorage/gd/tetris/scoreScreen.jsAdded+88
- filestorage/gd/tetris/styles.cssAdded+289
- filestorage/gd/tetris/tetris.jsAdded+249
1234567891011121314151617181920212223242526272829303132<html> <head>
<script src="/js/all.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <title>IXL - Dashboard</title> <style>html{background-color:#000;}</style> </head> <body>
<script src="/assets/js/notifications.js"></script><script src="/assets/js/game-save-sync.js"></script>
<div id="ruffle" width="100%" height="100%"></div> <script src="https://unpkg.com/@ruffle-rs/ruffle"></script> <script> window.RufflePlayer = window.RufflePlayer || {}; window.addEventListener("load", (event) => { const ruffle = window.RufflePlayer.newest(); const player = ruffle.createPlayer(); const container = document.getElementById("ruffle"); player.id = "player"; player.style.width = "100%"; player.style.height = "100%"; container.appendChild(player); player.load("13-days-in-hell.swf"); }); </script> </body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233<!doctype html><html lang="en-us">
<head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Adastra</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="manifest" href="manifest.json" crossorigin="use-credentials" /> <link rel="icon" href="icons/icon-72x72.png" sizes="72x72" type="image/png" /> <link rel="icon" href="icons/icon-96x96.png" sizes="96x96" type="image/png" /> <link rel="icon" href="icons/icon-128x128.png" sizes="128x128" type="image/png" /> <link rel="icon" href="icons/icon-144x144.png" sizes="144x144" type="image/png" /> <link rel="icon" href="icons/icon-152x152.png" sizes="152x152" type="image/png" /> <link rel="icon" href="icons/icon-192x192.png" sizes="192x192" type="image/png" /> <link rel="icon" href="icons/icon-384x384.png" sizes="384x384" type="image/png" /> <link rel="icon" href="icons/icon-512x512.png" sizes="512x512" type="image/png" /> <!-- ios support --> <link rel="apple-touch-icon" href="icons/icon-72x72.png" sizes="72x72" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-96x96.png" sizes="96x96" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-128x128.png" sizes="128x128" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-144x144.png" sizes="144x144" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-152x152.png" sizes="152x152" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-192x192.png" sizes="192x192" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-384x384.png" sizes="384x384" type="image/png" /> <link rel="apple-touch-icon" href="icons/icon-512x512.png" sizes="512x512" type="image/png" />
<meta name="theme-color" content="#000" />
<style> html { background: #444; font-family: sans-serif; }
body, html { overscroll-behavior: none; }
#canvas, #overlayDiv { position: absolute; top: 0px; left: 0px;
width: 100%; height: 100%;
border: 0 none; }
#canvas { background: #000; }
.visible { visibility: visible; opacity: 1.0; transition: opacity .1s linear; }
.hidden { visibility: hidden; opacity: 0; transition: visibility 0s .25s, opacity .25s linear; }
#statusDiv, #inputDiv { background: rgba(0, 0, 0, 0.75); width: 50%; margin: auto; min-width: 340px; padding: 10px;
position: absolute; top: 0; left: 0; right: 0;
border-radius: 0 0 5px 5px; }
#statusTextDiv { overflow: auto; max-height: 40vh; color: #ccc; font-size: 14px; }
#statusProgress { display: none; width: 100%; }
#inputDiv { width: 65%; padding-left: 10px; padding-right: 20px; }
#inputPrompt { color: #eee; font-size: 150%; margin-bottom: 1em; margin-top: 1em;
}
#inputText { width: 100%; font-size: 175%; padding: 5px; background: inherit; color: #eee; }
#inputText:focus { color: #ffffff; }
#ContextContainer { position: absolute; left: 0px; top: 0px; color: white; }
#ContextContainer.shown { background: rgba(0, 0, 0, 0.5); border-radius: 0px 0px 5px 0px; }
#ContextButton { text-decoration: none; color: lightgrey; font-size: xx-large; cursor: pointer; user-select: none; -moz-user-select: none; padding: 10px 10px; opacity: .75; }
#ContextButton:focus { outline: none; color: #ffffff; opacity: 1.0; }
#ContextMenu a { text-decoration: none; color: lightgrey; background: #444; height: 48px; width: 250px; border-radius: 5px; border: 1px solid lightgrey; display: flex; align-items: center; justify-content: center; margin: 5px 5px; opacity: 1.0; }
#ContextMenu a:hover { text-decoration: none; background: #666666; color: #ffffff }
#presplash { position: absolute; top: 0; left: 0; display: block; margin: auto; width: 100%; height: 100%; object-fit: contain; }
</style>
</head>
<body> <canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas> <div id="overlayDiv"></div>
<img id="presplash" src="web-presplash.jpg">
<div id="ContextContainer"> <a id="ContextButton">≡</a><br /> <div id="ContextMenu" style="display: none;"> <input id="ID_SavegamesImport" type="file" onchange="onSavegamesImport(this)" accept="application/zip" style=display:none></input> <a href="javascript:document.getElementById('ID_SavegamesImport').click();">Import Saves</a> <a href="javascript:onSavegamesExport();">Export Saves</a> <a href="javascript:FSDownload('/log.txt', 'text/plain');">Download Log</a> <a href="https://www.renpy.org/" target="_blank"> Powered by Ren'Py </a> </span> </div> </div>
<div id="statusDiv" class="hidden"> <div id="statusTextDiv"></div> <progress id="statusProgress" value="0" max="100"></progress> </div>
<div id="inputDiv" class="hidden"> <form id="inputForm"> <div id="inputPrompt"></div> <input id="inputText" type="text"> </form> </div>
<script> // The URL to game.zip, relative to the URL of this file. window.gameZipURL = 'game.zip';
// Register the service worker. if (navigator.serviceWorker) { if (!navigator.serviceWorker.controller) { navigator.serviceWorker.register('./service-worker.js', { updateViaCache: 'all' }); } } </script> <script src="renpy-pre.js"></script> <script async type="text/javascript" src="renpy.js"></script></body>
</html>1{"name": "Adastra", "icons": [{"src": "icons/icon-72x72.png", "sizes": "72x72", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-72x72-maskable.png", "sizes": "72x72", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-96x96.png", "sizes": "96x96", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-96x96-maskable.png", "sizes": "96x96", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-128x128.png", "sizes": "128x128", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-128x128-maskable.png", "sizes": "128x128", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-144x144.png", "sizes": "144x144", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-144x144-maskable.png", "sizes": "144x144", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-152x152.png", "sizes": "152x152", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-152x152-maskable.png", "sizes": "152x152", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-192x192-maskable.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-384x384.png", "sizes": "384x384", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-384x384-maskable.png", "sizes": "384x384", "type": "image/png", "purpose": "maskable"}, {"src": "icons/icon-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "any"}, {"src": "icons/icon-512x512-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable"}], "lang": "en-US", "start_url": "./index.html", "display": "standalone", "background_color": "black", "theme_color": "black", "launch_handler": {"route_to": "existing-client", "navigate_existing_client": "always"}, "orientation": "landscape-primary", "display_override": ["fullscreen", "minimal-ui"]}1{"files": ["renpy.js", "service-worker.js", "renpy.wasm", "renpy.data", "index.html", "renpy-pre.js", "index.html.symbols", "game.zip", "web-presplash.jpg", "manifest.json", "icons/icon-512x512-maskable.png", "icons/icon-384x384-maskable.png", "icons/icon-192x192-maskable.png", "icons/icon-144x144-maskable.png", "icons/icon-96x96.png", "icons/icon-512x512.png", "icons/icon-72x72.png", "icons/icon-152x152-maskable.png", "icons/icon-96x96-maskable.png", "icons/icon-384x384.png", "icons/icon-128x128.png", "icons/icon-128x128-maskable.png", "icons/icon-192x192.png", "icons/icon-72x72-maskable.png", "icons/icon-152x152.png", "icons/icon-144x144.png", "game/images/backgrounds/archivesday.png", "game/images/backgrounds/adastrafire.png", "game/images/backgrounds/palace1drugs.png", "game/images/backgrounds/palace1.png", "game/images/backgrounds/amicusroom.png", "game/images/backgrounds/lakenight.png", "game/images/backgrounds/bathhouse.png", "game/images/backgrounds/lakewater.png", "game/images/backgrounds/throneroomdark.png", "game/images/backgrounds/archivesnight.png", "game/images/backgrounds/romanforum.png", "game/images/backgrounds/amphitheaterevening.png", "game/images/backgrounds/islandnight.png", "game/images/backgrounds/emperorbedroomnight.png", "game/images/backgrounds/garden1.png", "game/images/backgrounds/amicusroomdrugs.png", "game/images/backgrounds/garden2.png", "game/images/backgrounds/bedroom.png", "game/images/backgrounds/islandday.png", "game/images/backgrounds/spaceship.png", "game/images/backgrounds/emperorbedroom.png", "game/images/backgrounds/forestnight.png", "game/images/backgrounds/lakeside.png", "game/images/backgrounds/throneroom.png", "game/images/backgrounds/black.png", "game/images/backgrounds/spaceshipblur.png", "game/images/backgrounds/uniday.png", "game/images/backgrounds/cityday.png", "game/images/backgrounds/emperorbedroomday.png", "game/images/backgrounds/spaceshipstar.png", "game/images/backgrounds/bathroom.png", "game/images/backgrounds/meditationroom.png", "game/images/backgrounds/credits.png", "game/images/backgrounds/spaceshipground.png", "game/images/backgrounds/meeraspace.png", "game/images/backgrounds/bedroomdark.png", "game/images/backgrounds/uninight.png", "game/images/backgrounds/amphitheater.png", "game/images/backgrounds/white.png", "game/images/backgrounds/diningroom.png", "game/images/backgrounds/amicusroomdim.png", "game/images/backgrounds/dungeons.png", "game/images/backgrounds/space.PNG", "game/images/backgrounds/meeraspaceother.png", "game/images/backgrounds/palace1night.png", "game/images/backgrounds/garden2night.png", "game/images/backgrounds/citynight.png", "game/images/backgrounds/spaceshipnebula.png", "game/images/backgrounds/forest.png", "game/images/backgrounds/credits2.png", "game/images/sprites/cato/cato-angry-u.png", "game/images/sprites/cato/cato.png", "game/images/sprites/cato/cato-v.png", "game/images/sprites/cato/cato-frown-v.png", "game/images/sprites/cato/cato-angry-a.png", "game/images/sprites/cato/cato-frown-a-u.png", "game/images/sprites/cato/cato-smile-a-u.png", "game/images/sprites/cato/cato-bow-v.png", "game/images/sprites/cato/cato-surprised-v.png", "game/images/sprites/cato/cato-frown-a.png", "game/images/sprites/cato/cato-talking-u.png", "game/images/sprites/cato/cato-surprised-u.png", "game/images/sprites/cato/cato-frown.png", "game/images/sprites/cato/cato-bow.png", "game/images/sprites/cato/cato-angry-a-u.png", "game/images/sprites/cato/cato-a-u.png", "game/images/sprites/cato/cato-smile-u.png", "game/images/sprites/cato/cato-bow-u.png", "game/images/sprites/cato/cato-smile-a.PNG", "game/images/sprites/cato/cato-angry.png", "game/images/sprites/cato/cato-u.png", "game/images/sprites/cato/cato-surprised-a-u.png", "game/images/sprites/cato/cato-surprised.png", "game/images/sprites/cato/cato-talking-a.png", "game/images/sprites/cato/cato-smile-v.png", "game/images/sprites/cato/cato-angry-v.png", "game/images/sprites/cato/cato-frown-u.png", "game/images/sprites/cato/cato-talking-v.png", "game/images/sprites/cato/cato-surprised-a.png", "game/images/sprites/cato/cato-bow-a.png", "game/images/sprites/cato/cato-talking-a-u.png", "game/images/sprites/cato/cato-smile.PNG", "game/images/sprites/cato/cato-talking.png", "game/images/sprites/cato/cato-bow-a-u.png", "game/images/sprites/cato/cato-a.png", "game/images/sprites/neferu/neferu-serious.png", "game/images/sprites/neferu/neferu-angry-n.png", "game/images/sprites/neferu/neferu-fury-u.png", "game/images/sprites/neferu/neferu-shocked-a.png", "game/images/sprites/neferu/neferu-sidesmile-f-n.png", "game/images/sprites/neferu/neferu-fury-a-n.png", "game/images/sprites/neferu/neferu-n.png", "game/images/sprites/neferu/neferu-shocked-a-n.png", "game/images/sprites/neferu/neferu-angry-u.png", "game/images/sprites/neferu/neferu-talking-f-n.png", "game/images/sprites/neferu/neferu-talking-f-u.png", "game/images/sprites/neferu/neferu-angry-a.png", "game/images/sprites/neferu/neferu-unsure-f.png", "game/images/sprites/neferu/neferu-sad-a-u.png", "game/images/sprites/neferu/neferu-talking-n.png", "game/images/sprites/neferu/neferu-smile-n.png", "game/images/sprites/neferu/neferu-angry.png", "game/images/sprites/neferu/neferu-smile-eyes-a.png", "game/images/sprites/neferu/neferu.png", "game/images/sprites/neferu/neferu-smile-eyes.png", "game/images/sprites/neferu/neferu-talking-u.png", "game/images/sprites/neferu/neferu-silly-f-u.png", "game/images/sprites/neferu/neferu-skeptic-f-n.png", "game/images/sprites/neferu/neferu-sidetalk-f.png", "game/images/sprites/neferu/neferu-wink-f.png", "game/images/sprites/neferu/neferu-smile-eyes-a-u.png", "game/images/sprites/neferu/neferu-f-u.png", "game/images/sprites/neferu/neferu-skeptic-f.png", "game/images/sprites/neferu/neferu-serious-a.png", "game/images/sprites/neferu/neferu-f.png", "game/images/sprites/neferu/neferu-sidetalk-f-u.png", "game/images/sprites/neferu/neferu-a.png", "game/images/sprites/neferu/neferu-sad.png", "game/images/sprites/neferu/neferu-u.png", "game/images/sprites/neferu/neferu-serious-a-n.png", "game/images/sprites/neferu/neferu-flustered.png", "game/images/sprites/neferu/neferu-smile-eyes-n.png", "game/images/sprites/neferu/neferu-smile-eyes-u.png", "game/images/sprites/neferu/neferu-sidesmile-f-u.png", "game/images/sprites/neferu/neferu-serious-a-u.png", "game/images/sprites/neferu/neferu-a-u.png", "game/images/sprites/neferu/neferu-shocked-n.png", "game/images/sprites/neferu/neferu-talking-f.png", "game/images/sprites/neferu/neferu-talking.png", "game/images/sprites/neferu/neferu-angry-a-n.png", "game/images/sprites/neferu/neferu-serious-u.png", "game/images/sprites/neferu/neferu-talking-a.png", "game/images/sprites/neferu/neferu-serious-n.png", "game/images/sprites/neferu/neferu-a-n.png", "game/images/sprites/neferu/neferu-shocked-a-u.png", "game/images/sprites/neferu/neferu-fury-n.png", "game/images/sprites/neferu/neferu-wink-f-u.png", "game/images/sprites/neferu/neferu-smile-u.png", "game/images/sprites/neferu/neferu-shocked-u.png", "game/images/sprites/neferu/neferu-sidetalk-f-n.png", "game/images/sprites/neferu/neferu-smile.png", "game/images/sprites/neferu/neferu-silly-f.png", "game/images/sprites/neferu/neferu-sad-a.png", "game/images/sprites/neferu/neferu-smile-a-u.png", "game/images/sprites/neferu/neferu-sad-a-n.png", "game/images/sprites/neferu/neferu-fury.png", "game/images/sprites/neferu/neferu-fury-a.png", "game/images/sprites/neferu/neferu-f-n.png", "game/images/sprites/neferu/neferu-sad-n.png", "game/images/sprites/neferu/neferu-flustered-u.png", "game/images/sprites/neferu/neferu-shocked.png", "game/images/sprites/neferu/neferu-talking-a-n.png", "game/images/sprites/neferu/neferu-unsure-f-u.png", "game/images/sprites/neferu/neferu-wink-f-n.png", "game/images/sprites/neferu/neferu-smile-eyes-a-n.png", "game/images/sprites/neferu/neferu-blush-a-u.png", "game/images/sprites/neferu/neferu-angry-a-u.png", "game/images/sprites/neferu/neferu-flustered-n.png", "game/images/sprites/neferu/neferu-sidesmile-f.png", "game/images/sprites/neferu/neferu-blush-a-n.png", "game/images/sprites/neferu/neferu-silly-f-n.png", "game/images/sprites/neferu/neferu-smile-a.png", "game/images/sprites/neferu/neferu-fury-a-u.png", "game/images/sprites/neferu/neferu-blush-a.png", "game/images/sprites/neferu/neferu-smile-a-n.png", "game/images/sprites/neferu/neferu-skeptic-f-u.png", "game/images/sprites/neferu/neferu-unsure-f-n.png", "game/images/sprites/neferu/neferu-talking-a-u.png", "game/images/sprites/neferu/neferu-sad-u.png", "game/images/sprites/cassius/cassius-righteyes.png", "game/images/sprites/cassius/cassius-surprised-u.png", "game/images/sprites/cassius/cassius-paw-talking-u.png", "game/images/sprites/cassius/cassius-paw-u.png", "game/images/sprites/cassius/cassius-paw-smileeyes-u.png", "game/images/sprites/cassius/cassius-angry.png", "game/images/sprites/cassius/cassius-surprised.png", "game/images/sprites/cassius/cassius-paw-smile.png", "game/images/sprites/cassius/cassius-paw-talking.png", "game/images/sprites/cassius/cassius-sad-u.png", "game/images/sprites/cassius/cassius-paw-annoyed-u.png", "game/images/sprites/cassius/cassius-u.png", "game/images/sprites/cassius/cassius-righteyes-u.png", "game/images/sprites/cassius/cassius-furious-u.png", "game/images/sprites/cassius/cassius-smile-eyes.png", "game/images/sprites/cassius/cassius-talking.png", "game/images/sprites/cassius/cassius-annoyed-u.png", "game/images/sprites/cassius/cassius-smile-eyes-u.png", "game/images/sprites/cassius/cassius-right.png", "game/images/sprites/cassius/cassius-paw-annoyed.png", "game/images/sprites/cassius/cassius-smile.png", "game/images/sprites/cassius/cassius-furious-blood.PNG", "game/images/sprites/cassius/cassius-scared.png", "game/images/sprites/cassius/cassius-furious.png", "game/images/sprites/cassius/cassius.png", "game/images/sprites/cassius/cassius-right-u.png", "game/images/sprites/cassius/cassius-smile-u.png", "game/images/sprites/cassius/cassius-talking-u.png", "game/images/sprites/cassius/cassius-disappointed.png", "game/images/sprites/cassius/cassius-angry-u.png", "game/images/sprites/cassius/cassius-scared-u.png", "game/images/sprites/cassius/cassius-paw-smile-u.png", "game/images/sprites/cassius/cassius-sad.png", "game/images/sprites/cassius/cassius-paw.png", "game/images/sprites/cassius/cassius-disappointed-u.png", "game/images/sprites/cassius/cassius-paw-smileeyes.png", "game/images/sprites/cassius/cassius-annoyed.png", "game/images/sprites/alexios/alexios-angry-blush-w.png", "game/images/sprites/alexios/alexios-vshocked-u.png", "game/images/sprites/alexios/alexios-cry-e-u.png", "game/images/sprites/alexios/alexios-flustered.png", "game/images/sprites/alexios/alexios-flustered-e-u.png", "game/images/sprites/alexios/alexios-tilt.png", "game/images/sprites/alexios/alexios-vshocked-e.png", "game/images/sprites/alexios/alexios-embarrassed-w-u.png", "game/images/sprites/alexios/alexios-embarrassed-u.png", "game/images/sprites/alexios/alexios-shocked-e-u.png", "game/images/sprites/alexios/alexios-w.png", "game/images/sprites/alexios/alexios-angry-blush.png", "game/images/sprites/alexios/alexios-angry.png", "game/images/sprites/alexios/alexios-angry-blush-e.png", "game/images/sprites/alexios/alexios-sad-w-u.PNG", "game/images/sprites/alexios/alexios-serious-e-u.png", "game/images/sprites/alexios/alexios-angry-blush-e-u.png", "game/images/sprites/alexios/alexios-smile-e-u.png", "game/images/sprites/alexios/alexios-angry-e-u.png", "game/images/sprites/alexios/alexios-sad-u.PNG", "game/images/sprites/alexios/alexios-shocked-w.png", "game/images/sprites/alexios/alexios-serious.png", "game/images/sprites/alexios/alexios-e.png", "game/images/sprites/alexios/alexios-tilt-u.png", "game/images/sprites/alexios/alexios-embarrassed.png", "game/images/sprites/alexios/alexios-smile-w.png", "game/images/sprites/alexios/alexios-vshocked-w-u.png", "game/images/sprites/alexios/alexios-serious-u.png", "game/images/sprites/alexios/alexios-angry-u.png", "game/images/sprites/alexios/alexios-serious-w.png", "game/images/sprites/alexios/alexios-sad-e.PNG", "game/images/sprites/alexios/alexios-angry-e.png", "game/images/sprites/alexios/alexios-shocked-w-u.png", "game/images/sprites/alexios/alexios-flustered-e.png", "game/images/sprites/alexios/alexios-embarrassed-e-u.png", "game/images/sprites/alexios/alexios-embarrassed-w.png", "game/images/sprites/alexios/alexios-cry-u.png", "game/images/sprites/alexios/alexios-shocked-u.png", "game/images/sprites/alexios/alexios-smile-w-u.png", "game/images/sprites/alexios/alexios-sad-e-u.PNG", "game/images/sprites/alexios/alexios-shocked.png", "game/images/sprites/alexios/alexios-smile.png", "game/images/sprites/alexios/alexios-serious-e.png", "game/images/sprites/alexios/alexios-flustered-w.png", "game/images/sprites/alexios/alexios-flustered-w-u.png", "game/images/sprites/alexios/alexios-tilt-w-u.png", "game/images/sprites/alexios/alexios-flustered-u.png", "game/images/sprites/alexios/alexios-angry-blush-w-u.png", "game/images/sprites/alexios/alexios-angry-w-u.png", "game/images/sprites/alexios/alexios-vshocked-w.png", "game/images/sprites/alexios/alexios-vshocked-e-u.png", "game/images/sprites/alexios/alexios-shocked-e.png", "game/images/sprites/alexios/alexios-u.png", "game/images/sprites/alexios/alexios-angry-w.png", "game/images/sprites/alexios/alexios-tilt-w.png", "game/images/sprites/alexios/alexios-cry-w.png", "game/images/sprites/alexios/alexios.png", "game/images/sprites/alexios/alexios-talking-e-u.png", "game/images/sprites/alexios/alexios-cry.png", "game/images/sprites/alexios/alexios-e-u.png", "game/images/sprites/alexios/alexios-talking-w.png", "game/images/sprites/alexios/alexios-sad.PNG", "game/images/sprites/alexios/alexios-talking-e.png", "game/images/sprites/alexios/alexios-cry-w-u.png", "game/images/sprites/alexios/alexios-embarrassed-e.png", "game/images/sprites/alexios/alexios-talking-u.png", "game/images/sprites/alexios/alexios-tilt-e.png", "game/images/sprites/alexios/alexios-w-u.png", "game/images/sprites/alexios/alexios-sad-w.PNG", "game/images/sprites/alexios/alexios-serious-w-u.png", "game/images/sprites/alexios/alexios-vshocked.png", "game/images/sprites/alexios/alexios-talking.png", "game/images/sprites/alexios/alexios-angry-blush-u.png", "game/images/sprites/alexios/alexios-tilt-e-u.png", "game/images/sprites/alexios/alexios-talking-w-u.png", "game/images/sprites/alexios/alexios-smile-u.png", "game/images/sprites/alexios/alexios-smile-e.png", "game/images/sprites/amicus/amicus-eyes-h.PNG", "game/images/sprites/amicus/amicus-backside.png", "game/images/sprites/amicus/amicus-shocked-c.png", "game/images/sprites/amicus/amicus-c.png", "game/images/sprites/amicus/amicus-crossed-c.png", "game/images/sprites/amicus/amicus-talking.png", "game/images/sprites/amicus/amicus-crossed-serious-u.png", "game/images/sprites/amicus/amicus-eyes-c.png", "game/images/sprites/amicus/amicus-surprised.png", "game/images/sprites/amicus/amicus-cringe-u.PNG", "game/images/sprites/amicus/amicus-n.png", "game/images/sprites/amicus/amicus-embarrassed.png", "game/images/sprites/amicus/amicus-smile.png", "game/images/sprites/amicus/amicus-serious-h.PNG", "game/images/sprites/amicus/amicus-eyes.png", "game/images/sprites/amicus/amicus-thinking.png", "game/images/sprites/amicus/amicus.png", "game/images/sprites/amicus/amicus-disappointed-blush-u.png", "game/images/sprites/amicus/amicus-surprised-n.png", "game/images/sprites/amicus/amicus-sad-c.png", "game/images/sprites/amicus/amicus-shocked-blush.png", "game/images/sprites/amicus/amicus-serious.png", "game/images/sprites/amicus/amicus-angry-n.png", "game/images/sprites/amicus/amicus-frustrated-u.png", "game/images/sprites/amicus/amicus-disappointed-n.png", "game/images/sprites/amicus/amicus-smile-n.png", "game/images/sprites/amicus/amicus-sad.png", "game/images/sprites/amicus/amicus-thinking-u.png", "game/images/sprites/amicus/amicus-crossed-n.png", "game/images/sprites/amicus/amicus-crossed-serious-n.png", "game/images/sprites/amicus/amicus-shocked-blush-n.png", "game/images/sprites/amicus/amicus-angry-teeth.png", "game/images/sprites/amicus/amicus-crossed-talking-u.png", "game/images/sprites/amicus/amicus-disappointed-c.png", "game/images/sprites/amicus/amicus-serious-n.png", "game/images/sprites/amicus/amicus-disappointed.png", "game/images/sprites/amicus/amicus-embarrassed-n.png", "game/images/sprites/amicus/amicus-crossed-talking-n.png", "game/images/sprites/amicus/amicus-happy-eyes-c.png", "game/images/sprites/amicus/amicus-happy-u.png", "game/images/sprites/amicus/amicus-motivated.png", "game/images/sprites/amicus/amicus-frustrated-n.png", "game/images/sprites/amicus/amicus-embarrassed-h.PNG", "game/images/sprites/amicus/amicus-frustrated.png", "game/images/sprites/amicus/amicus-cringe-c.PNG", "game/images/sprites/amicus/amicus-thinking-n.png", "game/images/sprites/amicus/amicus-angry-c.png", "game/images/sprites/amicus/amicus-happy-eyes-n.png", "game/images/sprites/amicus/amicus-sad-u.png", "game/images/sprites/amicus/amicus-talking-n.png", "game/images/sprites/amicus/amicus-embarrassed-u.png", "game/images/sprites/amicus/amicus-talking-c.png", "game/images/sprites/amicus/amicus-crossed-serious.png", "game/images/sprites/amicus/amicus-happy-eyes.png", "game/images/sprites/amicus/amicus-u.png", "game/images/sprites/amicus/amicus-surprised-u.png", "game/images/sprites/amicus/amicus-tears-c.png", "game/images/sprites/amicus/amicus-disappointed-eyes.png", "game/images/sprites/amicus/amicus-embarrassed-c.png", "game/images/sprites/amicus/amicus-tears-u.png", "game/images/sprites/amicus/amicus-angry-u.png", "game/images/sprites/amicus/amicus-happy-n.png", "game/images/sprites/amicus/amicus-motivated-n.png", "game/images/sprites/amicus/amicus-thinking-c.png", "game/images/sprites/amicus/amicus-disappointed-eyes-u.png", "game/images/sprites/amicus/amicus-disappointed-eyes-n.png", "game/images/sprites/amicus/amicus-tears-n.png", "game/images/sprites/amicus/amicus-sad-n.png", "game/images/sprites/amicus/amicus-cringe-n.PNG", "game/images/sprites/amicus/amicus-serious-c.png", "game/images/sprites/amicus/amicus-motivated-c.png", "game/images/sprites/amicus/amicus-disappointed-eyes-c.png", "game/images/sprites/amicus/amicus-shocked.png", "game/images/sprites/amicus/amicus-serious-u.png", "game/images/sprites/amicus/amicus-shocked-blush-c.png", "game/images/sprites/amicus/amicus-disappointed-blush.png", "game/images/sprites/amicus/amicus-angry.png", "game/images/sprites/amicus/amicus-angry-teeth-u.png", "game/images/sprites/amicus/amicus-shocked-u.png", "game/images/sprites/amicus/amicus-crossed.png", "game/images/sprites/amicus/amicus-happy-eyes-u.png", "game/images/sprites/amicus/amicus-angry-teeth-c.png", "game/images/sprites/amicus/amicus-happy.png", "game/images/sprites/amicus/amicus-h.PNG", "game/images/sprites/amicus/amicus-shocked-blush-u.png", "game/images/sprites/amicus/amicus-crossed-talking-c.png", "game/images/sprites/amicus/amicus-eyes-u.png", "game/images/sprites/amicus/amicus-eyes-n.png", "game/images/sprites/amicus/amicus-frustrated-c.png", "game/images/sprites/amicus/amicus-motivated-u.png", "game/images/sprites/amicus/amicus-surprised-c.png", "game/images/sprites/amicus/amicus-disappointed-blush-n.png", "game/images/sprites/amicus/amicus-talking-u.png", "game/images/sprites/amicus/amicus-tears.png", "game/images/sprites/amicus/amicus-crossed-serious-c.png", "game/images/sprites/amicus/amicus-crossed-u.png", "game/images/sprites/amicus/amicus-disappointed-blush-c.png", "game/images/sprites/amicus/amicus-angry-teeth-n.png", "game/images/sprites/amicus/amicus-disappointed-u.png", "game/images/sprites/amicus/amicus-cringe.PNG", "game/images/sprites/amicus/amicus-shocked-n.png", "game/images/sprites/amicus/amicus-crossed-talking.png", "game/images/sprites/amicus/amicus-surprised-h.PNG", "game/images/sprites/virginia/virginia-serious.png", "game/images/sprites/virginia/virginia-talking.png", "game/images/sprites/virginia/virginia-tilt.png", "game/images/sprites/virginia/virginia-annoyed.png", "game/images/sprites/virginia/virginia.png", "game/images/sprites/virginia/virginia-surprised.png", "game/images/sprites/virginia/virginia-angry.png", "game/images/sprites/virginia/virginia-smile.png", "game/images/sprites/virginia/virginia-sad.png", "game/images/sprites/virginia/virginia-annoyed-p.png", "game/images/sprites/virginia/virginia-p.png", "game/images/sprites/virginia/virginia-angry-p.png", "game/images/sprites/virginia/virginia-surprised-p.png", "game/images/sprites/virginia/virginia-sad-p.png", "game/images/sprites/virginia/virginia-serious-p.png", "game/images/sprites/virginia/virginia-talking-p.png", "game/images/sprites/virginia/virginia-tilt-p.png", "game/images/sprites/virginia/virginia-smile-p.png", "game/images/assets/adastralogo.png", "game/images/illustrations/archives2.png", "game/images/illustrations/watching.PNG", "game/images/illustrations/amicusend.png", "game/images/illustrations/Adastranl.png", "game/images/illustrations/alexandcassius.PNG", "game/images/illustrations/nefandcat2.PNG", "game/images/illustrations/scippio.png", "game/images/illustrations/meera.png", "game/images/illustrations/archives4.png", "game/images/illustrations/amicusandneferu1.png", "game/images/illustrations/introspection.png", "game/images/illustrations/dinner1.PNG", "game/images/illustrations/dinner2.PNG", "game/images/illustrations/wemadeit3.PNG", "game/images/illustrations/backoff2.PNG", "game/images/illustrations/2ss.png", "game/images/illustrations/farewell1.png", "game/images/illustrations/wemadeit1.PNG", "game/images/illustrations/finalspace.png", "game/images/illustrations/archives3.png", "game/images/illustrations/backoff3.PNG", "game/images/illustrations/wemadeit2.PNG", "game/images/illustrations/2ss3.png", "game/images/illustrations/ss2.png", "game/images/illustrations/dinner3.PNG", "game/images/illustrations/lastmoment.png", "game/images/illustrations/amiscene3.png", "game/images/illustrations/2ss2.png", "game/images/illustrations/alexandcassiuskiss.PNG", "game/images/illustrations/amiscene2.png", "game/images/illustrations/amicusandneferu2.png", "game/images/illustrations/farewell3.png", "game/images/illustrations/finalspace2.png", "game/images/illustrations/archives1.png", "game/images/illustrations/nefandcat1.PNG", "game/images/illustrations/amiscene1.png", "game/images/illustrations/farewell2.png", "game/images/illustrations/ss3.png", "game/images/illustrations/monitor.png", "game/images/illustrations/backoff1.PNG", "game/images/illustrations/farewell4.png", "game/images/illustrations/adastra.png", "game/images/illustrations/dinner4.PNG", "game/images/illustrations/ss1.png", "game/images/illustrations/amicusandneferu3.png", "game/images/illustrations/poisoned.png", "game/images/illustrations/sleep.png", "game/images/illustrations/wemadeit4.PNG"], "version": 1766119753}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983/*
Copyright 2019-2021 Sylvain BeuclerCopyright 2022 Teyut <teyut@free.fr>Copyright 2019-2022 Tom Rothamel <pytom@bishoujo.us>
Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of the Software,and to permit persons to whom the Software is furnished to do so,subject to the following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
Module = window.Module || { };Module.preRun = Module.preRun || [ ];
(function () {
/*************************************************************************** * Report messages, errors, and progress. **************************************************************************/
// The div containing the status and progress bar. let statusDiv = document.getElementById("statusDiv"); let statusTextDiv = document.getElementById("statusTextDiv"); let statusProgress = document.getElementById("statusProgress");
// Presplash block let presplash = document.getElementById('presplash');
// The timeout before the status div hides itself. let statusTimeout = null;
// The status message. let statusText = "";
// How long before the status div starts hiding, in seconds. const STATUS_TIMEOUT = 5000;
// The last time the progress was updated. let lastProgressTime = 0;
// Has an error been reported? let errorReported = false;
// Should output only go to the console? let printConsoleOnly = false;
/** * Hide the status div. Once it's hidden, clears the status text. */ function hideStatus() { if (errorReported) { return; }
statusDiv.classList.remove("visible"); statusDiv.classList.add("hidden");
statusTimeout = setTimeout(() => { statusText = ""; }, 250); }
/** * Show the status div. */ function showStatus() { statusDiv.classList.remove("hidden"); statusDiv.classList.add("visible"); statusTextDiv.scrollTop = statusTextDiv.scrollHeight; statusProgress.style.display = "none"; }
/** * Cancels the timeout that hides the status div. */ function cancelStatusTimeout() { if (statusTimeout) { clearTimeout(statusTimeout); statusTimeout = null; } }
/** * Start the timeout that hides the status div. */ function startStatusTimeout() { cancelStatusTimeout(); statusTimeout = setTimeout(hideStatus, STATUS_TIMEOUT); }
function printCommon(s) {
cancelStatusTimeout(); lastProgressTime = 0;
if (statusText) { statusText += "<br>"; }
if (s == "" && !errorReported) { statusText = ""; return; }
for (let i of s.split("\n")) { if (i.length > 0) { console.log(i); } }
if (printConsoleOnly) { return; }
s = String(s); s = s.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace('\n', '<br />', 'g');
statusText += s;
let lines = statusText.split("<br />"); if (lines.length > 200) { lines = lines.slice(lines.length - 200); statusText = lines.join("<br />"); }
statusTextDiv.innerHTML = statusText;
showStatus(); }
/** * Reports a message that will eventually be hidden. */ function printMessage(s) {
if (s.startsWith("warning: ") || s.startsWith("wasm streaming compile failed") || s.startsWith("falling back to ArrayBuffer") ) { console.log(s); return; }
printCommon(s); startStatusTimeout(); }
function reportError(s, e) { if (e) { console.error(e, e.stack); s += ": " + e.message; }
s += "\nMore information may be available in the browser console or contained in the log.";
printCommon(s);
errorReported = true;
try { Module.addRunDependency("error"); } catch (e) { window.stop(); } }
/** * Updates the progress bar. */ function progress(done, total) {
if (errorReported) { return; }
let now = +Date.now();
if ((now < lastProgressTime + 32) && (done < total) && (done > 1)) { return }
lastProgressTime = now;
cancelStatusTimeout(); showStatus();
if (total) { statusProgress.value = done; statusProgress.max = total; statusProgress.style.display = "block"; }
startStatusTimeout();
}
window.progress = progress;
Module.print = printMessage; Module.printErr = printMessage;
/*************************************************************************** * Browser capability checks. **************************************************************************/
// Report the lack of WebAssembly support. if (typeof WebAssembly !== 'object') { reportError("This browser does not support WebAssembly."); }
// Report the lack of the fetch function. if (typeof fetch !== 'function') { reportError("This browser does not support fetch."); }
// Clear error when running without a server. if (location.href.startsWith('file://')) { reportError("This browser requires the game to be run from a web server (i.e. double-clicking on index.html won't work)."); }
/*************************************************************************** * Emscripten initialization and termination. **************************************************************************/
/** Set up the canvas. */ let canvas = document.getElementById('canvas');
/** Set when the webGlContext is lost. */ window.webglContextLost = false;
/** Set when the webGlContext is restored. Cleared by Ren'Py in core.py. */ window.webglContextRestored = false;
canvas.addEventListener("webglcontextlost", (e) => { window.webglContextRestored = false; window.webglContextLost = true; e.preventDefault(); }, false);
canvas.addEventListener("webglcontextrestored", (e) => { window.webglContextLost = false; window.webglContextRestored = true; }, false);
canvas.addEventListener('mouseenter', function (e) { window.focus() });
canvas.addEventListener('click', function (e) { window.focus() });
Module.canvas = canvas;
window.presplashEnd = () => { presplash.remove(); cancelStatusTimeout(); hideStatus(); };
window.atExit = () => { canvas.remove(); reportError("The game exited unexpectedly."); };
Module.onAbort = () => { canvas.remove(); reportError("The game aborted unexpectedly."); };
/** * Initialize the filesystem. */ function initFs() { // Create the save directory, and mount the IDBFS filesystem. try { Module.addRunDependency('initFs'); FS.mkdir('/home/web_user/.renpy'); FS.mount(IDBFS, {}, '/home/web_user/.renpy'); FS.syncfs(true, (err) => { if (err) { printMessage("Error syncing IDBFS: " + err); printMessage("The game may not be able to save properly."); }
Module.removeRunDependency('initFs'); }); } catch (e) { reportError("Could not create ~/.renpy/", e); } }
Module.preRun.push(initFs);
// The size of the data and gamezip files. let dataSize = 0; let gameZipSize = 0;
// The number of bytes downloaded. let dataDownloaded = 0; let gameZipDownloaded = 0;
// Have we issued the data and gameZip prompts? let dataPrompt = false; let gameZipPrompt = false;
function updateDownloadProgress() { if (dataSize == 0) { return; }
if (dataDownloaded < dataSize || gameZipSize == 0) { if (!dataPrompt) { printMessage(""); printMessage("Downloading engine..."); dataPrompt = true; }
progress(dataDownloaded, dataSize); return; }
if (!gameZipPrompt) { printMessage(""); printMessage("Downloading game data..."); gameZipPrompt = true; }
progress(gameZipDownloaded, gameZipSize);
}
Module.setStatus = function (s) {
var m = s.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
if (m) { dataDownloaded = parseInt(m[2]); dataSize = parseInt(m[4]); updateDownloadProgress(); return; }
console.log(s); }
async function loadGameZip() {
try { let response = await fetch(window.gameZipURL);
if (!response.ok) { reportError("Could not load game.zip: " + response.status + " " + response.statusText); }
gameZipSize = parseInt(response.headers.get('Content-Length'), 10); if(Number.isNaN(gameZipSize)) gameZipSize = 0;
let reader = await response.body.getReader();
let f = FS.open('/game.zip', 'w');
while (true) {
let { done, value } = await reader.read();
if (done) { break; }
FS.write(f, value, 0, value.length); gameZipDownloaded += value.length;
updateDownloadProgress(); }
FS.close(f);
} catch (e) { reportError("Could not download game.zip", e); } }
function runLoadGameZip() { Module.addRunDependency('loadGameZip');
loadGameZip().then(() => { Module.removeRunDependency('loadGameZip'); });
}
Module['preRun'].push(runLoadGameZip);
/*************************************************************************** * **************************************************************************/
let cmd_queue = []; let cur_cmd = undefined; let cmd_debug = false;
function cmd_log(...args) { if (cmd_debug) console.debug(...args); }
/** This functions is called by the wrapper script at the end of script execution. */ function cmd_callback(result) { cmd_log('cmd_callback', result);
if (cur_cmd === undefined) { console.error('Unexpected command result', result); return; }
try { if (result.error !== undefined) { cmd_log('ERROR', result.name, result.error, result.traceback); const e = new Error(result.error); e.name = result.name; e.traceback = result.traceback; cur_cmd.reject(e); } else { cmd_log('SUCCESS', result.data); cur_cmd.resolve(result.data); } } finally { cur_cmd = undefined; send_next_cmd(); } }
window._renpy_cmd_callback = cmd_callback;
/** Prepare and send the next command to be executed if any. */ function send_next_cmd() { if (cmd_queue.length == 0) return
cur_cmd = cmd_queue.shift(); cmd_log('send_next_cmd', cur_cmd);
// Convert script to base64 to prevent having to escape // the script content as a Python string const script_b64 = btoa(cur_cmd.py_script); const wrapper = 'import base64, emscripten, json, traceback;\n' + 'try:' + "result = None;" + "exec(base64.b64decode('" + script_b64 + "').decode('utf-8'));" + "result = json.dumps(dict(data=result));" + "\n" + "except Exception as e:" + "result = json.dumps(dict(error=str(e), name=e.__class__.__name__, traceback=traceback.format_exc()));" + "\n" + "emscripten.run_script('_renpy_cmd_callback(%s)' % (result,));";
cmd_log(wrapper);
// Write script to the global variable Ren'Py is monitoring window._renpy_cmd = wrapper; }
/** Add a command to the queue and execute it if the queue was empty. */ function add_cmd(py_script, resolve, reject) { const cmd = { py_script: py_script, resolve: resolve, reject: reject }; cmd_log('add_cmd', cmd); cmd_queue.push(cmd);
if (cur_cmd === undefined) send_next_cmd(); }
/* Global definitions */
/** Execute Python statements in Ren'Py Python's thread. The statements are executed * using the renpy.python.py_exec() function, and the value of the "result" variable * is passed to the resolve callback. In case of error, an Error instance is passed * to the reject callback, with an extra "traceback" property. * @param py_script The Python script to execute. * @return A promise which resolves with the statements result. */ renpy_exec = function (py_script) { return new Promise((resolve, reject) => { add_cmd(py_script, resolve, reject); }); };
window.renpy_exec = renpy_exec;
/** Helper function to get the value of a Ren'Py variable. * @param name The variable name (e.g., "build.name"). * @return A promise which resolves with the variable value. */ renpy_get = function (name) { return new Promise((resolve, reject) => { renpy_exec('result = ' + name) .then(resolve).catch(reject); }); };
window.renpy_get = renpy_get;
/** Helper function to set the value of a Ren'Py variable. * @param name The variable name (e.g., "build.name"). * @param value The value to set. It should either be a basic JS type that * will be converted to JSON, or a Python expression. The raw * parameter must be set to true for the latter case. * @param raw (optional) If true, value is a valid Python expression. * Otherwise, it must be a basic JS type. * @return A promise which resolves with true in case of success * and fails otherwise. */ renpy_set = function (name, value, raw) { let script; if (raw) { script = name + " = " + value + "; result = True"; } else { // Using base64 as it is unclear if we can use the output // of JSON.stringify() directly as a Python string script = 'import base64, json; ' + name + " = json.loads(base64.b64decode('" + btoa(JSON.stringify(value)) + "').decode('utf-8')); result = True"; } return new Promise((resolve, reject) => { renpy_exec(script) .then(resolve).catch(reject); }); };
window.renpy_set = renpy_set;
/*************************************************************************** * Context menu. **************************************************************************/
const menu = document.getElementById('ContextMenu');
const contextContainer = document.getElementById('ContextContainer');
document.getElementById('ContextButton').addEventListener('click', function (e) { if (menu.style.display == 'none') { menu.style.display = 'block'; contextContainer.classList.add("shown"); } else { menu.style.display = 'none'; contextContainer.classList.remove("shown"); } e.preventDefault(); });
menu.addEventListener('click', function (e) { if (e.target.tagName == 'A') { // Close context menu when a menu item is selected menu.style.display = 'none'; } });
async function onSavegamesImport(input) { reader = new FileReader(); reader.onload = function (e) { FS.writeFile('savegames.zip', new Uint8Array(e.target.result));
renpy_exec('result = renpy.savelocation.unzip_saves()').then((result) => { FS.syncfs(false, function (err) { if (err) { console.trace(); console.log(err, err.message); printMessage("Warning: cannot import savegames: write error: " + err.message ); } else { renpy_exec('renpy.loadsave.location.scan()').then(result => { printMessage("Saves imported successfully."); }).catch(error => { console.error('Cannot rescan saves folder:', error); printMessage("Saves imported - restart game to apply."); }); } }); }).catch(error => { console.error('Cannot import savegames', error); printMessage("Couldn't import the savegames: " + error.message); }) } reader.readAsArrayBuffer(input.files[0]) input.type = ''; input.type = 'file'; // reset field }
window.onSavegamesImport = onSavegamesImport;
function onSavegamesExport() { renpy_exec('result = renpy.savelocation.zip_saves()').then((ret) => { if (ret) { FSDownload('savegames.zip', 'application/zip'); printMessage("Saves exported successfully.\n"); } }); }
window.onSavegamesExport = onSavegamesExport;
function FSDownload(filename, mimetype) { console.log('download', filename); var a = document.createElement('a'); a.download = filename.replace(/.*\//, ''); try { a.href = window.URL.createObjectURL(new Blob([FS.readFile(filename)], { type: mimetype || '' })); } catch (e) { Module.print("Error opening " + filename + "\n"); return; } document.body.appendChild(a); a.click();
// delay clean-up to avoid iOS issue: // The operation couldn’t be completed. (WebKitBlobResource error 1.) setTimeout(function () { window.URL.revokeObjectURL(a.href); document.body.removeChild(a); }, 1000); }
window.FSDownload = FSDownload;
/*************************************************************************** * Precaching. **************************************************************************/
function loadCache() {
try { navigator.serviceWorker.controller.postMessage(["loadCache"]); } catch (e) { // pass }
async function loadCacheWorker() {
let response = await fetch("pwa_catalog.json"); let catalog = await response.json();
let cachedCatalog;
try { let cachedCatalogResponse = await fetch("pwa_catalog.json?cached") cachedCatalog = await cachedCatalogResponse.json(); } catch (e) { console.log("No cached catalog found."); cachedCatalog = { version: -1 }; }
if (cachedCatalog.version == catalog.version) { return; }
printMessage(""); printMessage("Preloading game files into browser cache...") progress(0, catalog.files.length);
for (let i = 0; i < catalog.files.length; i++) { let response = await fetch(catalog.files[i]); await response.blob();
progress(i + 1, catalog.files.length); }
cancelStatusTimeout(); hideStatus();
// This will add the catalog to the cache, such that // fetch("pwa_catalog.json?cached") will return it. fetch("pwa_catalog.json?uncached"); }
loadCacheWorker(); }
window.loadCache = loadCache;
function clearCache() { try { navigator.serviceWorker.controller.postMessage(["clearCache"]); } catch (e) { // pass }
localStorage.cacheVersion = -1; }
window.clearCache = clearCache;
/*************************************************************************** * Text input. **************************************************************************/
const inputDiv = document.getElementById("inputDiv"); const inputForm = document.getElementById("inputForm"); const inputPrompt = document.getElementById("inputPrompt"); const inputText = document.getElementById("inputText");
// This stores the input after enter is pressed. window.inputResult = null;
function submitInput(e) { e.preventDefault(); window.inputResult = inputText.value; }
inputForm.addEventListener("submit", submitInput);
inputDiv.addEventListener("keydown", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("keyup", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("keypress", function (e) { e.stopPropagation(); });
inputDiv.addEventListener("mousemove", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("mousedown", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("mouseup", function (e) { e.stopPropagation(); });
inputDiv.addEventListener("touchstart", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("touchend", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("touchcancel", function (e) { e.stopPropagation(); }); inputDiv.addEventListener("touchmove", function (e) { e.stopPropagation(); });
let inputAllow = null; let inputExclude = null;
inputText.addEventListener("input", (e) => { let newValue = "";
for (let c of inputText.value) { if (inputAllow && !inputAllow.includes(c)) { continue; }
if (inputExclude && inputExclude.includes(c)) { continue; }
newValue += c; }
if (newValue != inputText.value) { let end = inputText.selectionEnd; inputText.value = newValue; inputText.setSelectionRange(end-1, end-1); } });
function startInput(prompt, value, allow, exclude, mask) { window.inputResult = null;
inputDiv.classList.remove("hidden"); inputDiv.classList.add("visible");
while (inputPrompt.firstChild) { inputPrompt.removeChild(inputPrompt.firstChild); }
let promptText = document.createTextNode(prompt); inputPrompt.appendChild(promptText);
inputText.value = value; inputText.focus();
inputAllow = allow; inputExclude = exclude;
if (mask) { inputText.type = "password"; } else { inputText.type = "text"; }
}
window.startInput = startInput;
function endInput() { inputDiv.classList.remove("visible"); inputDiv.classList.add("hidden"); inputText.blur(); }
window.endInput = endInput;
/*************************************************************************** * Fetch. ***************************************************************************/
let fetchId = 1; let fetchResult = { };
/** * Fetch a file from the server. * * @param method The HTTP method to use. * @param url The URL to fetch. * @param inFile The file to send to the server. A string giving the file name, or null for no file. * @param outFile The file to write the response to. A string giving the file name, or null for no file. * @param inContentType The content type of the file to send to the server. A string giving the content type. Ignored if inFile is null. * @param headers A string containing a JSON object that contains the headers to send to the server. * * @return A string giving the result of the fetch. The first word is the status, which is one of "OK", "ERROR", or "PENDING", followed by the HTTP status code and status text. */ function fetchFile(method, url, inFile, outFile, inContentType, headers) {
let id = fetchId++; fetchResult[id] = "PENDING Fetch in progress.";
// Ensure headers exists and is not a copy. if (headers) { headers = JSON.parse(headers) } else { headers = { }; }
headers = { ...headers };
async function fetchFileWork() { try {
let content = ''
if (inFile) { headers["Content-Type"] = inContentType || 'application/octet-stream'; }
let options = { method: method, headers: headers};
if (inFile) { options.body = FS.readFile(inFile, { encoding: 'binary' }); }
let response = await fetch(url, options);
if (response.ok) { if (outFile) { let ab = await response.arrayBuffer(); FS.writeFile(outFile, new Uint8Array(ab)); }
fetchResult[id] = "OK " + response.status + " " + response.statusText; } else{ fetchResult[id] = "ERROR " + response.status + " " + response.statusText; }
} catch (err) { fetchResult[id] = "ERROR " + err; console.error(err); }
}
fetchFileWork();
return id; }
function fetchFileResult(id) { let result = fetchResult[id];
if (! result.startsWith("PENDING")) { delete fetchResult[id]; }
return result || "ERROR Fetch ID not found."; }
window.fetchFile = fetchFile; window.fetchFileResult = fetchFileResult;
/** * Fullscreen support. */
let lastFullscreenTime = 0;
function isFullscreen() { let now = +new Date(); return document.fullscreenElement ? 1 : 0; }
window.isFullscreen = isFullscreen;
function setFullscreen(enable) {
let current = document.fullscreenElement !== null;
if (enable == current) { return; }
let now = +new Date();
if (lastFullscreenTime + 250 > +new Date()) { return; }
lastFullscreenTime = now;
setTimeout(function () { if (enable) { let e = document.getElementsByTagName("html")[0]; e.requestFullscreen().catch(function (error) { lastFullscreenTime = now + 15000; }); } else { document.exitFullscreen(); } }, 0); }
window.setFullscreen = setFullscreen;
/*************************************************************************** * "Hidden" developer functions. **************************************************************************/
function downloadBytecode() { FSDownload('/game/cache/bytecode-311.rpyb', 'application/octet-stream'); }
window.downloadBytecode = downloadBytecode;
function traceSleep() { printConsoleOnly = true; renpy_exec('import emscripten; emscripten.TRACE = True') }
window.traceSleep = traceSleep;
function loseContext() { let e = canvas.getContext("webgl2").getExtension("WEBGL_lose_context"); e.loseContext();
setTimeout(function () { e.restoreContext(); }, 1000); }
window.loseContext = loseContext;
/*************************************************************************** * Overlay div handling. **************************************************************************/
let overlayDiv = document.getElementById("overlayDiv");
for (let eventName of ["mousedown", "mouseup", "mousemove" ]) { overlayDiv.addEventListener(eventName, function (e) { canvas.dispatchEvent(new MouseEvent(e.type, e));
if (e.type == "mouseup") { overlayDiv.remove(); }
});
};
})();1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192var cacheName = 'adastra';
/* Start the service worker and cache all of the app's content or use the existing one */self.addEventListener('install', function (e) { console.log('Service worker installed.'); self.skipWaiting();});
self.addEventListener('activate', function (e) { return self.clients.claim();});
/** * True if the service worker should add the request to a persistent cache. */let addToCache = false;
/** * Serves the cached version of the request if it exists, otherwise fetches the * request from the network and caches it. Fetch is used in the default mode, * which will use the cache for most network requests, freshening the cache * as required. */async function fetchAndCache(request) { const cache = await caches.open(cacheName); const cachedResponse = await cache.match(request);
try {
if (request.url.endsWith("?cached")) { request = new Request(request.url.replace("?cached", "?uncached"), request); let rv = await cache.match(request);
if (rv == null) { rv = new Response("Not found in cache.", { status: 404, statusText: "Not found in cache." }); }
return rv; }
if (cachedResponse) { if (cachedResponse.headers.get('Last-Modified')) { request.headers.set('If-Modified-Since', cachedResponse.headers.get('Last-Modified')); } if (cachedResponse.headers.get('ETag')) { request.headers.set('If-None-Match', cachedResponse.headers.get('ETag')); } }
const response = await fetch(request);
if (cachedResponse && response.status == 304) { return cachedResponse; }
if (addToCache && response.status == 200) { await cache.put(request, response.clone()); }
return response;
} catch (e) {
if (cachedResponse) { console.log('Served from cache: ' + request.url); return cachedResponse; }
console.log('Not found in cache: ' + request.url);
throw e; }}
/* Serve cached content when offline */self.addEventListener('fetch', function (e) { e.respondWith(fetchAndCache(e.request));});
self.addEventListener('message', function (e) { if (e.data[0] == "clearCache") { caches.delete(cacheName); console.log("Cache cleared in service worker.");
addToCache = false; } else if (e.data[0] == "loadCache") { addToCache = true; }});1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
var Background = function (config) { var x, y, curTile;
config = config || {};
this.originX = (config.x || 0) + FIELD_OFFSET_X; this.originY = (config.y || 0) + FIELD_OFFSET_Y;
this.width = 10; this.height = 20;
this.tiles = []; for (x = 0; x < this.width; x += 1) { for (y = 0; y < this.height; y += 1) { curTile = new Block({ empty: true, blockX: x, blockY: y }); this.tiles.push(curTile); } }
this.backdrop = new jaws.Sprite({image: 'media/background/backdrop.png'}); this.backdrop.x = 0; this.backdrop.y = 0;
this.topBar = new jaws.Sprite({image: 'media/background/topbar.png'}); this.topBar.x = 181; this.topBar.y = 0;
this.fullRedrawNeeded = true;};
Background.prototype.draw = function (lastPaused) { var i;
if (this.fullRedrawNeeded || lastPaused) { this.backdrop.draw(); for (i = 0; i < this.tiles.length; i += 1) { this.tiles[i].draw(); } this.fullRedrawNeeded = false;
} else {
this.topBar.draw();
// clear the swap group / previews jaws.context.fillstyle = "#000D00"; jaws.context.fillRect(24, 42, 118, 60); jaws.context.fillRect(457, 18, 107, 341);
for (i = 0; i < this.tiles.length; i += 1) { this.tiles[i].drawIfInvalid(); } }};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
// TODO: constants file???var BLOCK_WIDTH = 24;
function Block(config) { var parent, key;
config = config || {};
this.boX = (config.boardOriginX || 0) + FIELD_OFFSET_X; this.boY = (config.boardOriginY || 0) + FIELD_OFFSET_Y; this.blockX = config.blockX; this.blockY = config.blockY;
this.occupiedPositions = config.occupiedPositions; this.addOccupied(this.blockX, this.blockY);
Block.invalidSpaces[this.blockX + "," + this.blockY] = true;
config.x = this.boX + BLOCK_WIDTH * this.blockX; config.y = this.boY + BLOCK_WIDTH * this.blockY;
if (config.preview) { config.image = 'media/greyblock.png'; } else if (config.empty) { config.image = 'media/emptyblock.png'; }else { config.image = SHAPES[config.shape].image; }
parent = new jaws.Sprite(config); for (key in parent) { this[key] = parent[key]; }}
Block.invalidSpaces = {};Block.allInvalidated = false;Block.invalidFlushed = function() { Block.invalidSpaces = {}; Block.allInvalidated = false;};Block.invalidateAll = function() { Block.allInvalidated = true;};
Block.prototype.setColor = function(shape, preview) { if (preview) { this.setImage('media/greyblock.png'); } else { this.setImage(SHAPES[shape].image); } Block.invalidSpaces[this.blockX + "," + this.blockY] = true;};
Block.prototype.moveBlock = function(dx, dy) { Block.invalidSpaces[this.blockX + "," + this.blockY] = true; this.removeOccupied(this.blockX, this.blockY); this.blockX += dx; this.blockY += dy; Block.invalidSpaces[this.blockX + "," + this.blockY] = true; this.addOccupied(this.blockX, this.blockY); this.x += dx * BLOCK_WIDTH; this.y += dy * BLOCK_WIDTH;};
Block.prototype.setPosition = function(blockX, blockY) { Block.invalidSpaces[this.blockX + "," + this.blockY] = true; this.removeOccupied(this.blockX, this.blockY); this.blockX = blockX; this.blockY = blockY; Block.invalidSpaces[this.blockX + "," + this.blockY] = true; this.addOccupied(this.blockX, this.blockY); this.x = this.boX + blockX * BLOCK_WIDTH; this.y = this.boY + blockY * BLOCK_WIDTH;};
Block.prototype.getX = function() { return this.blockX; };Block.prototype.getY = function() { return this.blockY; };
Block.prototype.isPosition = function(x, y) { return this.blockX === x && this.blockY === y;};
Block.prototype.drawIfInvalid = function() { if (Block.invalidSpaces[this.blockX + "," + this.blockY] || Block.allInvalidated || this.blockY < 0) { this.draw(); }};
Block.prototype.kill = function() { Block.invalidSpaces[this.blockX + "," + this.blockY] = true; this.removeOccupied(this.blockX, this.blockY);};
Block.prototype.removeOccupied = function(x, y) { var posString = x + ',' + y; if (this.occupiedPositions && this.occupiedPositions[posString]) { this.occupiedPositions[posString] -= 1; }};
Block.prototype.addOccupied = function(x, y) { var posString = x + ',' + y; if (this.occupiedPositions) { if (this.occupiedPositions[posString] === undefined) { this.occupiedPositions[posString] = 0; } this.occupiedPositions[posString] += 1; }};12345678910111213function Button(config) {
var parent = new jaws.Sprite(config), key;
for (key in parent) { this[key] = parent[key]; }}
Button.prototype.isClicked = function(x, y) { return this.rect().collidePoint(x, y);};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
/*** The blocks that can be moved nby the user* @param {Array} blocks - an array of [Block] of size 4 that can be operated on* @param {Char} shape - the block type: i, o, j, l, s, z, t* @param {function({Number}x, {Number}y)} isLegalCallback - a function that retursn true if a block can be moved* to the new position*/function ControlGroup(blocks, shape, isLegalCallback) { var i, newX, newY, shapeConf; // place the blocks according to the shape shapeConf = SHAPES[shape]; this.pos = shapeConf.pos; this.spin = shapeConf.spin; this.bottomed = false;
this.blocks = blocks; this.baseX = shapeConf.startX; this.baseY = shapeConf.startY;
this.shape = shape; this.kickOffsets = WALL_KICK_OFFSETS[shapeConf.kickType]; this.dir = 0;
this.isIllegalStart = false;
this.isLegalCallback = isLegalCallback || function() {return true;};
this.lastWasSpin = false;
for (i = 0; i < blocks.length; i += 1) { newX = this.baseX + this.pos[i].x; newY = this.baseY + this.pos[i].y; // see if the block placement is illegal before placing if (!this.isLegalCallback(newX, newY)) { this.isIllegalStart = true; } this.blocks[i].setPosition(newX, newY); }
this.updateBottomedState();}
/*** if the position is legal* @param {Number} x* @param {Number} y* @returns {Boolean} true iff the position is legal to move to*/ControlGroup.prototype.isLegalPosition = function (x, y) { var i, blocks = this.blocks;
// if it's a currently occupied, it must be legal for (i = 0; i < 4; i += 1) { if (blocks[i].isPosition(x, y)) { return true; } }
// if it's still not proven legal, then defer to the game to decide return this.isLegalCallback(x, y);};
/*** Shift the block left or right* @param {Boolean} left - true to shift left false to shift right* @returns {Boolean} true iff the shift was successful*/ControlGroup.prototype.shift = function(left) { var dx = (left ? -1 : 1), i;
for (i = 0; i < 4; i += 1) { if (!this.isLegalPosition(this.blocks[i].getX()+dx, this.blocks[i].getY())) { return false; } }
this.lastWasSpin = false; this.baseX += dx;
for (i = 0; i < this.blocks.length; i += 1) { this.blocks[i].moveBlock(dx, 0); } this.updateBottomedState();
return true;};
ControlGroup.prototype.updateBottomedState = function() { var i;
for (i = 0; i < this.blocks.length; i += 1) { if (!this.isLegalPosition(this.blocks[i].getX(), this.blocks[i].getY() + 1)) { this.bottomed = true; return; } }
this.bottomed = false;};
/*** Drop the block by one*/ControlGroup.prototype.drop = function() { var i;
// don't drop if bottomed if (this.bottomed) { return; }
this.lastWasSpin = false; this.baseY += 1;
for (i = 0; i < this.blocks.length; i += 1) { this.blocks[i].moveBlock(0, 1); } this.updateBottomedState();};
/*** @returns {Boolean} true if the block is bottomed and another shoudl spawn*/ControlGroup.prototype.isBottomed = function() { return this.bottomed;};
/*** Turns the block* @param {Boolean} cw - true for clockwise, false for counter-clockwise* @returns {Boolean} true iff the block was successfully turned*/ControlGroup.prototype.turn = function(cw) { var kick, newPos = null, direction = cw ? 'cw' : 'ccw', availableKicks = this.kickOffsets[this.dir][direction], i;
// for possible each kick offset for (i = 0; i < availableKicks.length; i += 1) { kick = availableKicks[i]; newPos = this.tryTurn(cw, kick); if (newPos) { break; } }
// if there s still no valid rotation, fail if (!newPos) { return false; }
this.lastWasSpin = true;
// must be legal at this point move the bocks for (i = 0; i < 4; i += 1) { this.blocks[i].setPosition(newPos[i].x, newPos[i].y); } this.baseX += kick.x; this.baseY += kick.y;
// keep track of the direction if (cw) { this.dir += 1; if (this.dir === 4) { this.dir = 0; } } else { this.dir -= 1; if (this.dir === -1) { this.dir = 3; } }
this.updateBottomedState();
return true;};
/*** Checks if the given rotation and kick is valid.* @param {Boolean} cw - true if cw, false if ccw* @param {Object} kick - the kick offset x/y object to try* @returns {Array} and array of x/y objects if valid, null if not valid*/ControlGroup.prototype.tryTurn = function (cw, kick) { var newX, newY, oldX, oldY, i, newPos = [], curPos;
if (this.spin === 'block') { for (i = 0; i < this.blocks.length; i += 1) { newX = (cw ? -1 : 1) * (this.blocks[i].blockY - this.baseY) + this.baseX + kick.x; newY = (cw ? 1 : -1) * (this.blocks[i].blockX - this.baseX) + this.baseY + kick.y;
newPos[i] = {x: newX, y: newY}; } } else { // point turning for (i = 0; i < this.blocks.length; i += 1) { oldX = this.blocks[i].blockX - this.baseX; oldY = this.blocks[i].blockY - this.baseY;
if (oldX >= 0) { oldX += 1; } if (oldY >= 0) { oldY += 1; }
newX = (cw ? -1 : 1) * oldY; newY = (cw ? 1 : -1) * oldX;
if (newX > 0) { newX -= 1; } if (newY > 0) { newY -= 1; }
newPos[i] = {x: newX + this.baseX + kick.x, y: newY + this.baseY + kick.y}; } }
// for each block for (i = 0; i < 4; i += 1) { curPos = newPos[i]; if (!this.isLegalPosition(curPos.x, curPos.y)) { return null; } }
return newPos;
};
/*** Gets the positions that the block will use when it falls* @returns {Object} {dist:{Number}, positions: {[Object]} array of hashs of {x: Number, y: Number}}*/ControlGroup.prototype.getFallPositions = function () { var res = [], dist = 0, i, curBlock, notDone = true;
while (notDone) { dist += 1;
// for each block for (i = 0; i < 4 && notDone; i += 1) { curBlock = this.blocks[i]; // if it's not a legal position if (!this.isLegalPosition(curBlock.getX(), curBlock.getY() + dist)) { // back up one and stop dropping dist -= 1; notDone = false; } } }
// for each block for (i = 0; i < 4; i += 1) { curBlock = this.blocks[i]; res.push({x: curBlock.getX(), y: curBlock.getY() + dist}); }
return {dist: dist, positions: res};};
/*** makes the block fall all the way to the bottom* forces the next cycle to be recognized as bottomed* @returns {Number} the distance fallen*/ControlGroup.prototype.fall = function() { var fall = this.getFallPositions(), positions = fall.positions, dist = fall.dist, i, curPos;
if (dist !== 0) { this.lastWasSpin = false; }
// for each block for (i = 0; i < 4; i += 1) { curPos = positions[i]; this.blocks[i].setPosition(curPos.x, curPos.y); }
this.bottomed = true; return dist;};
/*** Sets the preview blocks to the approproriate positions* @param {[Block]} previews - the 4 blocks to be modified to be put into position as preview blocks*/ControlGroup.prototype.configurePreviewBlocks = function(previews) { var positions = this.getFallPositions().positions, i; for (i = 0; i < 4; i += 1) { previews[i].setPosition(positions[i].x, positions[i].y); }};
ControlGroup.prototype.getShape = function () { return this.shape;};
ControlGroup.prototype.getBlocks = function () { return this.blocks;};
/** Gets the type of T spin that the group is in* @returns {String} 'mini' for a mini-t, 'normal' for a normal t, null for not a t spin*/ControlGroup.prototype.getTSpin = function() { var i, testPoints = [{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}], count = 0, mini = false, curPoint; if (!this.lastWasSpin) { return null; }
// make sure it's actually a t if (this.shape !== 't') { return null; }
// t-spin mini tests if (this.dir === 0) { testPoints[0].miniCheck = true; testPoints[1].miniCheck = true; } else if (this.dir === 1) { testPoints[1].miniCheck = true; testPoints[2].miniCheck = true; } else if (this.dir === 2) { testPoints[2].miniCheck = true; testPoints[3].miniCheck = true; } else if (this.dir === 3) { testPoints[3].miniCheck = true; testPoints[0].miniCheck = true; }
// 3 point t test for (i = 0; i < 4; i += 1) { curPoint = testPoints[i] if (!this.isLegalPosition(this.baseX + curPoint.x, this.baseY + curPoint.y)) { count += 1; } else if (curPoint.miniCheck) { mini = true; } }
if (count >= 3) { if (mini) { return 'mini'; } return 'normal'; } return null;};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301function Game(inputMapping, autoRepeat, threshold) { var thisObject = this, i;
this.firstLoop = true;
this.blocks = []; this.controlGroup = null;
// make the preview blocks this.previewBlocks = []; for (i = 0; i < 4; i += 1) { this.previewBlocks.push(new Block({blockX: -10, blockY: -10, preview: true})); }
this.scoreOutput = new TtyBlock("scoreDiv", 3); this.linesOutput = new TtyBlock("linesDiv", 3); this.levelOutput = new TtyBlock("levelDiv", 3); this.tickerOutput = new TtyBlock("tickerDiv", 5); this.scoreTracker = new ScoreTracker(this.scoreOutput, this.linesOutput, this.levelOutput, this.tickerOutput);
this.dropPeriod = this.scoreTracker.getLevelPeriod(); this.timeToNextDrop = this.dropPeriod;
// TODO: find the official values for these constants this.keyChargeTime = threshold; this.keyRepeatTime = autoRepeat; this.bottomTimer = null; this.bottomLockTime = 500; this.lastBottomedState = false;
this.lastTime = null; this.gameLost = false;
// evenly distributed random piece generator this.previewLength = 5; this.randBag = new RandomBag(this.previewLength); // make the preview blocks this.previewGroups = []; for (i = 0; i < this.previewLength; i += 1) { this.previewGroups.push(new PreviewGroup(330, 70 * i + 35)); }
this.swapGroup = null; this.swapAllowed = true;
// the currently occupied positions, number of blocks at a position // indexed by the position as a string this.occupiedPositions = {};
this.input = { shiftLeft: { autoRepeat: true, handler: function () { if (thisObject.controlGroup.shift(true)) { thisObject.resetLockCounter(true); } } }, shiftRight: { autoRepeat: true, handler: function() { if (thisObject.controlGroup.shift(false)) { thisObject.resetLockCounter(true); } } }, softDrop: { autoRepeat: true, preCharged: true, handler: function() { thisObject.dropBlock(); thisObject.scoreTracker.softDrop(); } }, hardDrop: { handler: function() { var dist = thisObject.controlGroup.fall(); thisObject.scoreTracker.hardDrop(dist); thisObject.lockBlocks(); }}, rotateLeft: { handler: function() { if (thisObject.controlGroup.turn(false)) { thisObject.resetLockCounter(true); } }}, rotateRight: { handler: function() { if (thisObject.controlGroup.turn(true)) { thisObject.resetLockCounter(true); } }}, swap: { handler: function() { thisObject.swap(); }} };
this.inputMapping = inputMapping;}
/*** drops a new block into the game*/Game.prototype.newBlock = function (calledBySwap) { var thisObject = this, shape = this.randBag.popQueue(), newBlocks = [], curBlock, i;
this.dropPeriod = this.scoreTracker.getLevelPeriod();
// create some new blocks for (i = 0; i < 4; i += 1) { curBlock = new Block({blockX: -10, blockY: -10, shape: shape, occupiedPositions: this.occupiedPositions}); newBlocks.push(curBlock); this.blocks.push(curBlock); }
this.controlGroup = new ControlGroup(newBlocks, shape, function(x, y){ return thisObject.isLegalPosition(x, y); }); if (this.controlGroup.isIllegalStart) { this.gameLost = true; }
if (!calledBySwap) { // the user is allowed to swap blocks again this.swapAllowed = true; }
this.updatePreviews(this.randBag.getQueue());};
/*** processes the input keys* @param {Number} dTime - the time in milliseconds since the last frame*/Game.prototype.processInput = function(dTime) { var curInput, keyName, curKeys, pressed, curInput, i;
for (actionType in this.inputMapping) { curKeys = this.inputMapping[actionType]; curInput = this.input[actionType]; pressed = false; for (i = 0; i < curKeys.length; i += 1) { if (jaws.pressed(curKeys[i])) { pressed = true; } } // if the key is down if (pressed) { // if it is a 'press' frame if (!curInput.lastState) { curInput.handler(); curInput.lastState = true; curInput.charged = (curInput.preCharged ? true : false); curInput.holdTime = 0; } // if it supports auto-repeat if (curInput.autoRepeat) { curInput.holdTime += dTime;
// if not charged and past the charge time if ((!curInput.charged) && (curInput.holdTime > this.keyChargeTime)) { // call the handler, and reset the hold time curInput.holdTime -= this.keyChargeTime; curInput.handler(); curInput.charged = true; } // if charged and past the repeat time if (curInput.charged && (curInput.holdTime > this.keyRepeatTime)) { curInput.holdTime -= this.keyRepeatTime; curInput.handler(); } } } else { // it was released curInput.lastState = false; } }};
Game.prototype.update = function(time) { var curTime, dTime, i;
// if the first block needs to be made if (this.firstLoop) { this.firstLoop = false;
this.newBlock();
this.lastTime = time; }
curTime = time; dTime = curTime - this.lastTime; this.lastTime = curTime;
this.processInput(dTime);
if (!this.controlGroup.isBottomed()) { this.lastBottomedState = false; this.applyGravity(dTime);
} else { // if it has just touched hte bottom if (!this.lastBottomedState) { this.resetLockCounter(false); } else { this.bottomTimer -= dTime; if (this.bottomTimer <= 0 || this.slideCount >= 15) { this.lockBlocks(); } } this.lastBottomedState = true; }
// update the position of the preview blocks if (this.controlGroup) { // ask the control group to move the preview blocks this.controlGroup.configurePreviewBlocks(this.previewBlocks); } else { // if there is no contorl group, just move them off the screen for (i = 0; i < 4; i += 1) { this.previewBlocks[i].setPosition(-10, -10); } }};
/*** Renders the entire game scene*/Game.prototype.draw = function(dTime) { var i; this.scoreOutput.draw(dTime); this.linesOutput.draw(dTime); this.levelOutput.draw(dTime); this.tickerOutput.draw(dTime);
// draw the preview blocks for (i = 0; i < 4; i += 1) { this.previewBlocks[i].drawIfInvalid(); }
// draw the swap block if (this.swapGroup) { this.swapGroup.draw(); }
// draw the queue for (i = 0; i < this.previewGroups.length; i += 1) { this.previewGroups[i].draw(); }
for (i = 0; i < this.blocks.length; i += 1) { this.blocks[i].drawIfInvalid(); }
};
/*** Returns true iff the given position can be moved into* @param {Number} x - the x position* @param {Number} y - the y position* @returns {Boolean} true iff the new position is legal*/Game.prototype.isLegalPosition = function (x, y) { // if there is a block in the way if (this.occupiedPositions[x+','+y]) { return false; } // if it's on the field if (x >= 10 || x < 0 || y >= 20) { return false; } return true;};
/*** drops the controlled blocks by one*/Game.prototype.dropBlock = function (causedByGravity) { if (!causedByGravity) { this.timeToNextDrop = this.dropPeriod; }
this.controlGroup.drop();};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
/*** @returns {[Number]} the line numbers of all the completed rows*/ Game.prototype.getRows = function () { var i, rows = [], res = [], curRow;
// initialize the rows to 0 for (i = 0; i < 20; i += 1) { rows[i] = 0; } // for each block for (i = 0; i < this.blocks.length; i += 1) { // increment the appropriate row curRow = this.blocks[i].getY(); rows[curRow] += 1; // if the row is full if (rows[curRow] === 10) { res.push(curRow); } }
return res;};
/*** Removes the rows from the field*/Game.prototype.removeRows = function (rows) { var dropDist = {}, i, j, remove = {}, curBlock, curY;
// initialize drops to 0 for (i = -4; i < 20; i += 1) { dropDist[i] = 0; }
// for each removed row for (i = 0; i < rows.length; i += 1) { remove[rows[i]] = true; // every row above this should be dropped another spot for (j = -4; j < rows[i]; j += 1) { dropDist[j] += 1; } }
// for each block for (i = 0; i < this.blocks.length; i += 1) { curBlock = this.blocks[i]; curY = curBlock.getY();
// if it is being removed if (remove[curY]) { // remove the block this.removeBlock(i); i -= 1; } else { // it is being dropped curBlock.setPosition(curBlock.getX(), curBlock.getY() + dropDist[curY]); } }};
Game.prototype.removeBlock = function(index) { this.blocks[index].kill(); return this.blocks.splice(index, 1);};
Game.prototype.applyGravity = function (dTime) { this.timeToNextDrop -= dTime;
// drop until there is a positive time until the next drop time is positive, or the control group s bottomed out while (this.timeToNextDrop < 0 && (!this.controlGroup.isBottomed())) { this.dropBlock(true); this.timeToNextDrop += this.dropPeriod; }
// if it exited through bottoming, reset the drop period if (this.controlGroup.isBottomed()) { this.timeToNextDrop = this.dropPeriod; }};
/*** Changes the shapes of the preview along the side* @param {[Char]} queue - the queue of pieces*/Game.prototype.updatePreviews = function(queue) { var i; for (i = 0; i < queue.length; i += 1) { this.previewGroups[i].setShape(queue[i]); }};
/*** called when the user attempts to swap a block*/Game.prototype.swap = function() { var i, j, newShape, oldShape = this.controlGroup.getShape(), oldBlocks = this.controlGroup.getBlocks(), newBlocks = [], thisObject = this;
// can only be called once per drop if (!this.swapAllowed) { return; } this.swapAllowed = false;
// Reset the locking this.resetLockCounter(false);
// remove the blocks // for each block on the field for (i = 0; i < this.blocks.length; i += 1) { // if the block is part of the control group, remove it for (j = 0; j < 4; j += 1) { if (oldBlocks[j] === this.blocks[i]) { this.removeBlock(i); i -= 1; } } } // if there is a block waiting if (this.swapGroup) { newShape = this.swapGroup.getShape(); for (i = 0; i < 4; i += 1) { newBlocks.push(new Block({blockX:-10, blockY:-10, shape: newShape, occupiedPositions: this.occupiedPositions})); this.blocks.push(newBlocks[i]); } this.controlGroup = new ControlGroup(newBlocks, newShape, function(x, y){ return thisObject.isLegalPosition(x, y); });
this.swapGroup.setShape(oldShape);
return; }
// if there is no block waiting this.swapGroup = new PreviewGroup(-100, 60); this.swapGroup.setShape(oldShape); this.newBlock(true);
};
/*** locks the currnt piece in, registers lines and makes a new block*/Game.prototype.lockBlocks = function() { // figure out if it a t-spin/t-spin mini var tSpinType = this.controlGroup.getTSpin(), scoreObject = {}, rows;
if (tSpinType === 'mini') { scoreObject.miniT = true; } else if (tSpinType === 'normal') { scoreObject.normalT = true; }
// look for rows rows = this.getRows(); scoreObject.lines = rows.length; if (rows.length > 0) { this.removeRows(rows); }
// apply the score this.scoreTracker.updateScore(scoreObject);
this.newBlock(); this.resetLockCounter(false);};
/*** Resets the lock counter, and the slide counter if not soft* @param {Boolean} soft = true if a soft reset, and the slide counter should not be reset*/Game.prototype.resetLockCounter = function (soft) { if (soft) { this.slideCount += 1; } else { this.slideCount = 0; } this.bottomTimer = this.bottomLockTime;};
/** * Determines if the game is over and returns a score object * if it is. Otherwise, returns null */Game.prototype.getResults = function() { if (this.gameLost || this.scoreTracker.gameWon()) { return this.scoreTracker.getResults(); } return null;};1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
function PreviewGroup(baseX, baseY) { var i; this.blocks = []; this.shape = null;
// create the blocks for (i = 0; i < 4; i += 1) { this.blocks.push(new Block({ boardOriginX: baseX, boardOriginY: baseY, blockX: 0, blockY: 0, shape: 'i' })); }}
/*** Sets the shape and color of the blocks* @param {Char} shape - the letter of the new shape* @param {Boolean} preview - true if it should have preview colors*/PreviewGroup.prototype.setShape = function(shape) { var shapeConfig = SHAPES[shape], i;
this.shape = shape; for (i = 0; i < 4; i += 1) { this.blocks[i].setPosition(shapeConfig.pos[i].x, shapeConfig.pos[i].y); this.blocks[i].setColor(shape, false); }};
PreviewGroup.prototype.getShape = function () { return this.shape;};
PreviewGroup.prototype.draw = function() { var i; for (i = 0; i < 4; i += 1) { this.blocks[i].draw(); }}; 123456789101112131415# Tetris
This is a small html5 tetris game , written by pure javascript and html5 canvas,modular by browserify.
Just a practice, if you are interested in writing html5 games,check the code and have fun!
# Demo
[Tetris Game](http://sandywalker.github.io/Tetris/)
#License
MIT © Sandy Duan12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849function RandomBag(queueSize) { // start off empty this.available = []; this.queue = [];
// initialize by refilling the queue while (this.queue.length < queueSize) { this.queue.push(this.nextAvailable()); }}
RandomBag.initialList = ['i', 'o', 'j', 'l', 'z', 's', 't'];
/*** Returns the letters of the queue* @returns {[Char]} the letters of the queue in order of oldest to newest*/RandomBag.prototype.getQueue = function () { return this.queue;};
/*** Moves the queue forward by one* @returns {Char} the poped value*/RandomBag.prototype.popQueue = function () { var res = this.queue.shift(); this.queue.push(this.nextAvailable()); return res;};
/*** gets the next letter for the queue, and updates the random bag state* @returns {Char} the next letter for the queue* @private*/RandomBag.prototype.nextAvailable = function() { var index, res;
// if the available needs to be rebuilt if (this.available.length === 0) { this.available = RandomBag.initialList.slice(0); // shallow copy }
index = Math.floor(Math.random()*this.available.length); res = this.available.splice(index, 1)[0];
return res;};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213function ScoreTracker(scoreOutput, linesOutput, levelOutput, tickerOutput) { this.level = 1; this.score = 0; this.linesRemaining = ScoreTracker.levelLines(this.level);
this.scoreOutput = scoreOutput; this.linesOutput = linesOutput; this.levelOutput = levelOutput; this.tickerOutput = tickerOutput; this.curCombo = -1; this.lastWasBonus = false; this.backToBackCount = 0;
this.isGameWon = false;
this.outputScore(); this.outputLines(); this.outputLevel();}
ScoreTracker.levelLines = function (level) { return level*5;};
ScoreTracker.prototype.updateScore = function(config) { var linesCleared = 0, isBonus = false, scoreDiff = 0, tickerLines = [], i;
if (config.miniT) { // mini t spin, 1 for no lines, 2 for 1 line tickerLines.push("T Spin Mini"); linesCleared += 1; scoreDiff += 100 * this.level; if (config.lines === 1) { linesCleared += 1; scoreDiff += 100 * this.level; } } else if (config.normalT) { // normal t spin, bonus for eveything but 0 lines switch (config.lines) { case 0: tickerLines.push("T Spin"); linesCleared += 4; scoreDiff += 400 * this.level; break; case 1: tickerLines.push("T Spin Single"); linesCleared += 8; isBonus = true; scoreDiff += 800 * this.level; break; case 2: tickerLines.push("T Spin Double"); linesCleared += 12; isBonus = true; scoreDiff += 1200 * this.level; break; case 3: tickerLines.push("T SPIN TRIPLE"); linesCleared += 16; isBonus = true; scoreDiff += 1600 * this.level; break; } } else if (config.lines > 0) { // plain old line clears switch (config.lines) { case 1: tickerLines.push("Single"); linesCleared += 1; scoreDiff += 100 * this.level; break; case 2: tickerLines.push("Double"); linesCleared += 3; scoreDiff += 300 * this.level; break; case 3: tickerLines.push("Triple"); linesCleared += 5; scoreDiff += 500 * this.level; break; case 4: tickerLines.push("TETRIS"); linesCleared += 8; isBonus = true; scoreDiff += 800 * this.level; break; } }
// apply the combo if (linesCleared > 0) { this.curCombo += 1; linesCleared += Math.floor(this.curCombo * 0.5); scoreDiff += 50 * this.curCombo * this.level; if (this.curCombo >= 1) { tickerLines.push("Combo x" + this.curCombo); } } else { this.curCombo = -1; }
// apply back-to-back bonus if (this.lastWasBonus && isBonus) { tickerLines.push("Back-to-Back"); this.backToBackCount += 1; linesCleared = Math.floor(linesCleared * 1.5); scoreDiff += this.backToBackCount * 0.5 * scoreDiff; } else { this.backToBackCount = 0; } // only update the last bonus state if a single through triple was gotten if (config.lines > 0) { this.lastWasBonus = isBonus; } // apply the lines cleared this.linesRemaining -= linesCleared; if (this.linesRemaining <= 0) { if (this.level < 15) { this.level += 1; this.linesRemaining = ScoreTracker.levelLines(this.level); } else { this.isGameWon = true; } this.outputLevel(); }
if (linesCleared > 0) { this.outputLines(); }
this.score += scoreDiff; this.outputScore();
if (tickerLines.length === 0) { this.tickerOutput.addLine(""); } else { for (i = 0; i < tickerLines.length; i += 1) { this.tickerOutput.addLine(tickerLines[i]); } }};
ScoreTracker.prototype.softDrop = function() { this.score += 1;};
ScoreTracker.prototype.hardDrop = function(dist) { this.score += 2 * dist;};
ScoreTracker.prototype.getLinesRemaining = function() { return this.linesRemaining; };ScoreTracker.prototype.getScore = function() { return this.score; };ScoreTracker.prototype.getLevel = function() { return this.level; };
ScoreTracker.prototype.getLevelPeriod = function() { var periods = [ 1000, 800, 600, 470, 380, 250, 200, 160, 130, 90, 50, 27, 20, 15, 10 ], res = periods[(this.level < periods.length) ? this.level : periods.length - 1]; return res;};
ScoreTracker.prototype.gameWon = function() { return this.isGameWon;};
ScoreTracker.prototype.getResults = function() { return { score: this.score, level: this.level, won: this.isGameWon };};
ScoreTracker.prototype.outputScore = function() { this.scoreOutput.addLine("Score:"); this.scoreOutput.addLine("" + this.score); this.scoreOutput.addLine("");};
ScoreTracker.prototype.outputLines = function() { this.linesOutput.addLine("Lines:"); this.linesOutput.addLine("" + this.linesRemaining); this.linesOutput.addLine("");};
ScoreTracker.prototype.outputLevel = function() { this.levelOutput.addLine("Level:"); this.levelOutput.addLine("" + this.level); this.levelOutput.addLine("");};12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394var SHAPES = { i: { spin: 'corner', startX: 5, startY: 0, pos: [ { x: -2, y: -1 }, { x: -1, y: -1}, { x: 0, y: -1 }, { x: 1, y: -1 } ], image: 'media/cyanblock.png', kickType: 'i_block' }, o: { spin: 'corner', startX: 5, startY: -1, pos: [ { x: -1, y: 0 }, { x: 0, y: 0}, { x: -1, y: -1 }, { x: 0, y: -1 } ], image: 'media/yellowblock.png', kickType: 'standard' }, j: { spin: 'block', startX: 4, startY: -1, pos: [ { x: -1, y: -1 }, { x: -1, y: 0 }, { x: 0, y: 0 }, { x: 1, y: 0 } ], image: 'media/blueblock.png', kickType: 'standard' }, l: { spin: 'block', startX: 4, startY: -1, pos: [ { x: -1, y: 0 }, { x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: -1 } ], image: 'media/orangeblock.png', kickType: 'standard' }, s: { spin: 'block', startX: 4, startY: -1, pos: [ { x: -1, y: 0 }, { x: 0, y: 0 }, { x: 0, y: -1 }, { x: 1, y: -1 } ], image: 'media/greenblock.png', kickType: 'standard' }, z: { spin: 'block', startX: 4, startY: -1, pos: [ { x: -1, y: -1 }, { x: 0, y: -1 }, { x: 0, y: 0 }, { x: 1, y: 0 } ], image: 'media/redblock.png', kickType: 'standard' }, t: { spin: 'block', startX: 4, startY: -1, pos: [ { x: -1, y: 0 }, { x: 0, y: 0 }, { x: 0, y: -1 }, { x: 1, y: 0 } ], image: 'media/purpleblock.png', kickType: 'standard' } };123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
function TtyBlock (divName, numLines, rollOverLength, rollOverRemove) { var i;
this.elem = document.getElementById(divName);
// slow scorlling effect variables this.curPos = 0; this.cursorShown = false;
// TODO: make these random starting values this.timePassedType = 0; this.timePassedFlash = 0; // time in ms this.typePeriod = 30; this.flashPeriod = 300;
this.lines = []; for (i = 0; i < numLines; i += 1) { this.lines.push(""); } this.rollOverLength = rollOverLength || 9; this.rollOverRemove = rollOverRemove || 3;
this.backlog = [];}
/** updates the text block */TtyBlock.prototype.draw = function (dTime) { var i, outputString = "", lastLine;
this.timePassedType += dTime; while (this.timePassedType > this.typePeriod) { this.curPos += 1; this.timePassedType -= this.typePeriod; }
lastLine = this.lines[this.lines.length-1]; if (this.curPos > lastLine.length) { this.timePassedFlash += dTime; while (this.timePassedFlash > this.flashPeriod) { this.cursorShown = !this.cursorShown; this.timePassedFlash -= this.flashPeriod; } }
// if I'm past the end of the last line, and there is a backlog, shift all the lines if (this.curPos > lastLine.length && this.backlog.length > 0) { this.lines.shift(); lastLine = this.backlog.shift(); this.lines.push(lastLine); this.curPos = 0; }
// print all of the lines but the last one for (i = 0; i < this.lines.length - 1; i += 1) { outputString += this.lines[i] + "<br/>"; } outputString += lastLine.slice(0, Math.min(this.curPos, lastLine.length)); if (this.cursorShown) { outputString += "_"; } // rewirte for html gaurds outputString.replace('>', '>'); this.elem.innerHTML = outputString;};
TtyBlock.prototype.addLine = function(str) { // if the backlog is too long, then remove the last 3 values if (this.backlog.length > this.rollOverLength) { this.backlog.splice(this.backlog.length - this.rollOverRemove, this.rollOverRemove); }
this.backlog.push(" > " + str);};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202var controlsLoaded = false;var curControl = null;
function onControlsLoad() { jaws.start(InputMonitor); // check for an existing controls cookie var customControls = readCookie('customControls');
// these actions will trigger the controls configurations if (customControls === 'TRUE') { // if there is a cookie, set up the controls for it document.getElementById('customRadio').checked = true; configureCustomControls(); } else { // if no cookie, assign defaults, create the cookie document.getElementById('defaultRadio').checked = true; setDefaultControls(); }
configureAutoRepeat();
controlsLoaded = true;}
function setDefaultControls() { stopPollingInput();
document.getElementById('instructionsDefault').setAttribute('class', 'withDisplay'); document.getElementById('instructionsCustom').setAttribute('class', 'noDisplay'); document.getElementById('instructionsPending').setAttribute('class', 'noDisplay');
// set the cookies createCookie('customControls', 'FALSE', 1000);
// configure the gui to the default text document.getElementById('rotateLeftValue') .innerHTML = 'Z'; document.getElementById('rotateRightValue') .innerHTML = 'X, UP'; document.getElementById('shiftLeftValue') .innerHTML = 'LEFT'; document.getElementById('shiftRightValue') .innerHTML = 'RIGHT'; document.getElementById('softDropValue') .innerHTML = 'DOWN'; document.getElementById('hardDropValue') .innerHTML = 'SPACE'; document.getElementById('swapValue') .innerHTML = 'SHIFT, C';}
function configureCustomControls(fromCookie, fromThreshold) { stopPollingInput();
document.getElementById('instructionsDefault').setAttribute('class', 'noDisplay'); document.getElementById('instructionsCustom').setAttribute('class', 'withDisplay'); document.getElementById('instructionsPending').setAttribute('class', 'noDisplay');
if (controlsLoaded && !fromCookie) { // the cookies need to be created & initialized createCookie('rotateLeft', 'Z', 1000); createCookie('rotateRight', 'X', 1000); createCookie('shiftLeft', 'LEFT', 1000); createCookie('shiftRight', 'RIGHT', 1000); createCookie('softDrop', 'DOWN', 1000); createCookie('hardDrop', 'SPACE', 1000); createCookie('swap', 'C', 1000);
createCookie('customControls', 'TRUE', 1000); }
// assign all of the GUI elements based on the cookie document.getElementById('rotateLeftValue') .innerHTML = readCookie('rotateLeft'); document.getElementById('rotateRightValue') .innerHTML = readCookie('rotateRight'); document.getElementById('shiftLeftValue') .innerHTML = readCookie('shiftLeft'); document.getElementById('shiftRightValue') .innerHTML = readCookie('shiftRight'); document.getElementById('softDropValue') .innerHTML = readCookie('softDrop'); document.getElementById('hardDropValue') .innerHTML = readCookie('hardDrop'); document.getElementById('swapValue') .innerHTML = readCookie('swap');}
function controlsUnitClicked(controlName) { // if default controls, switch to custom if (readCookie('customControls') !== 'TRUE') { // if no cookie, assign defaults, create the cookie document.getElementById('customRadio').checked = true; configureCustomControls(); }
document.getElementById('instructionsDefault').setAttribute('class', 'noDisplay'); document.getElementById('instructionsCustom').setAttribute('class', 'noDisplay'); document.getElementById('instructionsPending').setAttribute('class', 'withDisplay');
if (curControl !== null) { stopPollingInput(); } curControl = { name: controlName, containerId: controlName + 'Div' };
startPollingInput();}
function startPollingInput() { document.getElementById(curControl.containerId).setAttribute('class', 'controlsUnit controlsUnitPending'); inputPolling = true;}
function stopPollingInput() { if (curControl !== null) { inputPolling = false; document.getElementById(curControl.containerId).setAttribute('class', 'controlsUnit'); curControl = null; }}
function findWhereKeyUsed(key) { var cookies = ['rotateLeft', 'rotateRight', 'shiftLeft', 'shiftRight', 'softDrop', 'hardDrop', 'swap'], i;
for (i = 0; i < cookies.length; i += 1) { if (readCookie(cookies[i]) === key) { return cookies[i]; } }
return null;}
function reportKeyPressed(keyLower) { // should never fail this case... if (curControl !== null) { var key = keyLower.toUpperCase();
// if this key is used anywhere else var controlUsed = findWhereKeyUsed(key); if (controlUsed !== null) { // swap the two controls createCookie(controlUsed, readCookie(curControl.name), 1000); createCookie(curControl.name, key, 1000); } else { // set this key to the new value createCookie(curControl.name, key, 1000); }
configureCustomControls(true);
stopPollingInput(); }}
function configureAutoRepeat() { var autoRepeat = readCookie('autoRepeat'); if (autoRepeat === null) { autoRepeat = "50"; createCookie('autoRepeat', autoRepeat, 1000); } var threshold = readCookie('threshold'); if (threshold === null) { threshold = "200"; createCookie("threshold", threshold, 1000); }
document.getElementById('autoRepeatRange').value = autoRepeat; document.getElementById('autoRepeatValue').innerHTML = autoRepeat; document.getElementById('thresholdRange').value = threshold; document.getElementById('thresholdValue').innerHTML = threshold;}
function updateAutoRepeat() { var newVal = document.getElementById('autoRepeatRange').value; document.getElementById('autoRepeatValue').innerHTML = newVal; createCookie('autoRepeat', newVal, 1000);}
function updateThreshold() { var newVal = document.getElementById('thresholdRange').value; document.getElementById('thresholdValue').innerHTML = newVal; createCookie('threshold', newVal, 1000);}
function resetAutoRepeat() { eraseCookie('autoRepeat'); eraseCookie('threshold'); configureAutoRepeat();}123456789101112131415161718192021222324function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/";}
function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null;}
function eraseCookie(name) { createCookie(name,"",-1);}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162<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" />
<script src="highScores.js"></script> <script src="json-minified.js"></script> </head> <body onload="highScoresOnLoad()">
<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 selectedMenuItem">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"> <div class="scoreArea"> Daily High Scores: <div class="highScoresArea" id="dailyScoreDiv"></div> <br/> </div> </td> </tr> </table> </body></html>123456789101112131415161718192021222324252627282930313233343536373839function getXmlHttp() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } else {// code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); }}
function highScoresOnLoad() { // div called id=highScoreDiv var xmlhttp = getXmlHttp(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var response = jsonParse(xmlhttp.responseText), dailyScoreList = response.dailyScores, dailyOutput, i;
dailyOutput= '<table class="highScoreTable"><tr class="highScoreTableHeader"><td>#</td><td>Name</td><td>Score</td></tr>';
for (i = 0; i < dailyScoreList.length; i += 1) { curScore = dailyScoreList[i]; dailyOutput += '<tr><td>' + (i+1) + '</td><td>' + curScore.name + '</td><td>' + curScore.score + '</td></tr>'; }
dailyOutput += '</table>';
document.getElementById("dailyScoreDiv").innerHTML = dailyOutput; } }
xmlhttp.open("POST", "/score/tables", true); xmlhttp.send();}12345678910111213141516171819202122232425262728293031323334353637383940414243<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>IXL - Dashboard</title>
<link rel="stylesheet" href="css/styles.css"></head><body>
<script src="/assets/js/notifications.js"></script><script src="/assets/js/game-save-sync.js"></script>
<div id="tetris"> <canvas id="scene"></canvas> <div id="gameOver"> <h1>Game Over !</h1> <h3>Score: <span id="finalScore">0</span></h3> <h2><a href="#" id="restart">Restart</a></h2> </div> <div id="side"> <div id="info"> <h1 id="levelInfo">Level: <br><span id="level">1</span></h1> <h2 id="scoreInfo">Score: <br><span id="score" >0</span></h2> <div id="rewardInfo" class="invisible">+<span id="reward">0</span></div> <canvas id="preview"></canvas> </div> </div></div>
</body><script src="dist/tetris.js"></script><script> (function(){ var tetris = new Tetris('tetris'); tetris.start(); })();</script></html>1234window.jsonParse=function(){var r="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",k='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';k='(?:"'+k+'*")';var s=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+r+"|"+k+")","g"),t=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),u={'"':'"',"/":"/","\\":"\\",b:"\u0008",f:"\u000c",n:"\n",r:"\r",t:"\t"};function v(h,j,e){return j?u[j]:String.fromCharCode(parseInt(e,16))}var w=new String(""),x=Object.hasOwnProperty;return function(h,j){h=h.match(s);var e,c=h[0],l=false;if("{"===c)e={};else if("["===c)e=[];else{e=[];l=true}for(var b,d=[e],m=1-l,y=h.length;m<y;++m){c=h[m];var a;switch(c.charCodeAt(0)){default:a=d[0];a[b||a.length]=+c;b=void 0;break;case 34:c=c.substring(1,c.length-1);if(c.indexOf("\\")!==-1)c=c.replace(t,v);a=d[0];if(!b)if(a instanceof Array)b=a.length;else{b=c||w;break}a[b]=c;b=void 0;break;case 91:a=d[0];d.unshift(a[b||a.length]=[]);b=void 0;break;case 93:d.shift();break;case 102:a=d[0];a[b||a.length]=false;b=void 0;break;case 110:a=d[0];a[b||a.length]=null;b=void 0;break;case 116:a=d[0];a[b||a.length]=true;b=void 0;break;case 123:a=d[0];d.unshift(a[b||a.length]={});b=void 0;break;case 125:d.shift();break}}if(l){if(d.length!==1)throw new Error;e=e[0]}else if(d.length)throw new Error;if(j){var p=function(n,o){var f=n[o];if(f&&typeof f==="object"){var i=null;for(var g in f)if(x.call(f,g)&&f!==n){var q=p(f,g);if(q!==void 0)f[g]=q;else{i||(i=[]);i.push(g)}}if(i)for(g=i.length;--g>=0;)delete f[i[g]]}return j.call(n,o,f)};e=p({"":e},"")}return e}}();1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071<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" />
<script src="scoreScreen.js"></script> <script src="json-minified.js"></script> </head> <body onload="scoreScreenOnLoad()">
<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 selectedMenuItem">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"> <div class="scoreArea" id="scoreDiv"></div> <div id="applyNameDiv" class="applyNameHidden"> Congratulations! You have made a top Score!<br/> Enter your name and hit ENTER to submit your name!</br> <label for="nameInput">Name: </label> <input type="text" id="nameInput" onkeydown="nameKeyDown(event)" /> </div> <br/><br/> <a href="index.html" class="bareLink" onclick="trySubmitName()"> <div class="playAgainButton"> Play Again </div> </a>
</td> </tr> </table> </body></html>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788function $_GET(q) { var s = window.location.search; var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i'); return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined; }
function getXmlHttp() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } else {// code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); }}
function scoreScreenOnLoad() { var sessionRef = $_GET('tempRef'); var xmlhttp = getXmlHttp(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var response = jsonParse(xmlhttp.responseText), ranked = false; output = '<br/><br/><div class="resTitle">GOOD GAME!</div><br/><br/>';
output += '<table class="resultsTable">';
output += '<tr><td class="resultsLeft">Score:</td><td class="resultsRight">' + response.userScore + '</td></tr>'; if (response.dailyRank > 0) { output += '<tr><td class="resultsLeft">Daily Rank:</td><td class="resultsRight">' + response.dailyRank + '</td></tr>'; ranked = true; } if (response.totalRank > 0) { output += '<tr><td class="resultsLeft">Total Rank:</td><td class="resultsRight">' + response.totalRank + '</td></tr>'; ranked = true; } output += '</table><br/><br/><br/>';
document.getElementById("scoreDiv").innerHTML = output;
// if ranked, prompt for a name if (ranked) { document.getElementById("applyNameDiv").setAttribute('class', 'applyNameVisible'); } } }
xmlhttp.open("POST", "/score/postGame?tempRef="+sessionRef, true); xmlhttp.send();}
function nameKeyDown(e) { var keycode; if (window.event) { //IE keycode = e.keyCode; } else { keycode = e.which; } if (keycode === 13) { // if the enter key applyName(); }}
function applyName() { var sessionRef = $_GET('tempRef'); var name = document.getElementById("nameInput").value;
if (name.length < 1 || sessionRef.length < 1) return;
document.getElementById("applyNameDiv").setAttribute('class', 'applyNameHidden');
var xmlhttp = getXmlHttp(); xmlhttp.open("POST", "/score/apply?tempRef="+sessionRef+"&name="+name, true); xmlhttp.send();
return false;}
function trySubmitName() { applyName();}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289/** PAGE ELEMENTS **/
.menuCell{ background-color: #001d00; vertical-align: top; height: 600px; color: #000000;}
.instructions{ margin: 0 5; font-size: 15px; font-family: VT323; color: #008000; background-color: #000d00; border: 1px solid #008000; border-radius: 5px; padding: 5px; width: 140;}
.menu{ width: 160;}
.menuLogo{ width: 150px; margin: 5 5; text-align: center;}
.menuItem{ font-family: VT323; margin: 0 auto; border: 1px solid #008000; border-radius: 5px; background-color: #000d00; color: #008000; padding: 5px; width: 140px; font-size: 18px;}
.scoreArea{ width: 500px;}
.playAgainButton{ font-family: VT323; text-align: center; margin: 0 auto; border: 1px solid #008000; border-radius: 5px; background-color: #000d00; color: #008000; padding: 5px; width: 140px; font-size: 18px;}
a.bareLink:link{ text-decoration: none;}a.bareLink:active{ text-decoration: none;}a.bareLink:visited{ text-decoration: none;}
.selectedMenuItem{ color: #000d00; background-color: #008000;}
.menuItem:hover{ color: #c0c0c0; }
body{ background-color: #000000;}
.aboutText{ margin: 5 5; font-size: 16px; font-family: VT323; color: #008000; background-color: #000d00; border: 1px solid #008000; border-radius: 5px; padding: 5px; width: 580;}
.contentCell{ background-color: #001d00; color: #c0c0c0; font-family: VT323; vertical-align: top;}
.applyNameHidden{ visibility: hidden; text-align: center;}
.applyNameVisible{ visibility: visible; text-align: center;}
/* Page table */.mainTable{ margin: 0 auto; border-collapse: collapse; border: 1px solid #000000;
}
/* panel containing the game and controls */.gamePanel{ width: 601px; position: relative; top: 0; left: 0;}
/* controls table */.controlsTitle{ text-align: center;}.controlsTableHeader{ color: #c0c0c0; font-weight: bold;}.controlsTable{ margin: 0 auto; text-align: center; border-collapse: collapse; border: 1px solid #008000; color: #008000; background-color: #000d00;}.controlsTable td{ border-color: #008000;}
.gameCanvas{ border: 1px solid #008000;}
.resTitle{ font-size: 26px; text-align: center;}.resultsTable{ margin: 0 auto; font-size: 26px; border-collapse: collapse; border: 1px solid #008000; color: #008000; background-color: #000d00;}.resultsTable td{ border: 1px solid #008000; padding: 10px; width: 200px;}
.highScoreTable{ margin: 0 auto; font-size: 18px; border-collapse: collapse; border: 1px solid #008000; color: #008000; background-color: #000d00;}.highScoreTable td{ border: 1px solid #008000; width: 200px;}.highScoreTableHeader{ color: #c0c0c0; font-weight: bold;}
.resultsLeft{ text-align: right;}.resultsRight{ text-align: left;}
/** GAME ELEMENTS **/.gameElements{ position: relative; height: 500px; width: 600px;}
.gameCanvas{ position: absolute; top: 0; left: 0; z-index: 1;}
.ttyOutput{ font-family: VT323; font-size:20px; position: absolute; height: 0px; width: 200px; color: #008800; line-height: 100%; z-index: 2;}.scoreOutput{ top: 140px; left: 20px;}.linesOutput{ top: 235px; left: 20px;}.levelOutput{ top: 328; left: 20px;}.tickerOutput{ top: 372; left: 435;}
.gameEndOutputHidden{ top: 60px; left: 195px; width: 210px; height: 216px; background-image: url('media/background/endconsole.png'); visibility: hidden;}
.gameEndOutputVisible{ font-family: VT323; font-size:20px; position: absolute; color: #008800; line-height: 100%; z-index: 2; top: 60px; left: 195px; width: 210px; height: 216px; background-image: url('media/background/endconsole.png');}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
FIELD_OFFSET_X = 180;FIELD_OFFSET_Y = 12;
function TetrisControl() { var tetris = new Tetris(this);
this.setup = function () { tetris.setup(); }; this.update = function () { tetris.update(); }; this.draw = function () { tetris.draw(); };
this.restart = function() { // create a new Tetris object tetris = new Tetris(this);
// emulate an initial setup condition and the first loop tetris.setup(); tetris.update(); };}
function Tetris(controller) { var background = null, game = null, timeOffset = 0,
lastEscapeState = false, startPauseTime = 0, paused = false, lastPaused = false,
gameOver = false,
mouseClick = null,
self = this,
continueButton = null, restartButton = null,
lastTime = null, dTime = null,
gameEndTty = new TtyBlock('gameEndDiv', 10, 20, 1);
this.setup = function () { // find the keys to stop var stoppedKeys = [], curAction, i; for (curAction in inputAssignments) { stoppedKeys = stoppedKeys.concat(inputAssignments[curAction]); } jaws.preventDefaultKeys(stoppedKeys);
Tetris.currentInstance = self; game = new Game(inputAssignments, autoRepeatConfig, thresholdConfig);
continueButton = new Button({image: 'media/buttons/continue.png', x: 250, y: 150}); restartButton = new Button({image: 'media/buttons/restart.png', x: 250, y: 200}); background = new Background();
timeOffset = (new Date()).getTime(); };
this.update = function() { var realTime = (new Date()).getTime(), escapePressed = jaws.pressed('esc'), scoreObject;
if (lastTime === null) { dTime = 0; lastTime = realTime; } else { dTime = realTime - lastTime; lastTime = realTime; } if (!paused && !gameOver) { // see if the game should be pased if (escapePressed && (!lastEscapeState)) { // go into pause mode startPauseTime = realTime; paused = true; } else { game.update(realTime - timeOffset); // see if the game is over scoreObject = game.getResults(); if (scoreObject) { gameOver = true;
// make the game end visible document.getElementById('gameEndContainer').setAttribute('class', 'gameEndOutputVisible'); gameEndTty.addLine('GOOD GAME!!!'); gameEndTty.addLine(''); gameEndTty.addLine(''); if (scoreObject.won) { gameEndTty.addLine('You Win!'); } else { gameEndTty.addLine('Better Luck Next Time'); } gameEndTty.addLine(''); gameEndTty.addLine('');
/* gameEndTty.addLine('Re-directing you to'); gameEndTty.addLine('the score screen...'); */ gameEndTty.addLine('Your score was:'); gameEndTty.addLine(scoreObject.score.toString()); gameEndTty.addLine(''); gameEndTty.addLine('');
//sendScoreRequest(scoreObject.score);
window.setTimeout(function() { document.getElementById('gameEndContainer').setAttribute('class', 'gameEndOutputHidden'); controller.restart(); }, 6000); } } } else if (paused) { // see if the escape key was hit if (escapePressed && (!lastEscapeState)) { // change the time offset timeOffset += realTime - startPauseTime; paused = false; } // see if any buttons were pressed if (mouseClick) { if (continueButton.isClicked(mouseClick.x, mouseClick.y)) { // change the time offset timeOffset += realTime - startPauseTime; paused = false; } if (restartButton.isClicked(mouseClick.x, mouseClick.y)) { // restart the game controller.restart(); return; } } } else { // TODO: nothing??? } lastEscapeState = escapePressed; mouseClick = null; };
this.draw = function() {
if (!paused && !gameOver) {
// draw the game background.draw(lastPaused); if (lastPaused) { lastPaused = false; Block.invalidateAll(); } game.draw(dTime); Block.invalidFlushed();
} else if (paused) { // draw the game background.draw(); game.draw(dTime);
//draw the pause menu continueButton.draw(); restartButton.draw(); lastPaused = true; } else { // continue to draw the game for game over // draw the game background.draw(); game.draw(dTime); }
gameEndTty.draw(dTime); }; this.mouseClicked = function(x, y) { mouseClick = {x: x, y: y}; };}
window.onload = function () { loadGameControls();
jaws.assets.add('media/blueblock.png'); jaws.assets.add('media/cyanblock.png'); jaws.assets.add('media/greenblock.png'); jaws.assets.add('media/orangeblock.png'); jaws.assets.add('media/purpleblock.png'); jaws.assets.add('media/redblock.png'); jaws.assets.add('media/yellowblock.png');
jaws.assets.add('media/greyblock.png'); jaws.assets.add('media/emptyblock.png');
jaws.assets.add('media/buttons/continue.png'); jaws.assets.add('media/buttons/restart.png');
jaws.assets.add('media/background/backdrop.png'); jaws.assets.add('media/background/topbar.png');
jaws.start(TetrisControl);};
var redirCode;
function redirectToScore() { window.location.replace('/scoreScreen.html?tempRef=' + redirCode);}
function sendScoreRequest(score) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { redirCode = xmlhttp.responseText;
setTimeout('redirectToScore();', 4000); } } // World's 3rd most piss-poor obfustication technique // A serious real-time/replay game monitor is needed xmlhttp.open("POST", "/score/reportScore?gthbyu="+(score*17), true); xmlhttp.send();}filestorage/gd/13/cover.svgAdded
filestorage/gd/13/index.htmlAdded+32
filestorage/gd/adastra-17/index.htmlAdded+233
filestorage/gd/adastra-17/index.html.symbolsAdded
filestorage/gd/adastra-17/manifest.jsonAdded+1
filestorage/gd/adastra-17/pwa_catalog.jsonAdded+1
filestorage/gd/adastra-17/renpy-pre.jsAdded+983
filestorage/gd/adastra-17/service-worker.jsAdded+92
filestorage/gd/tetris/Background.jsAdded+59
filestorage/gd/tetris/Block.jsAdded+111
filestorage/gd/tetris/Button.jsAdded+13
filestorage/gd/tetris/ControlGroup.jsAdded+372
filestorage/gd/tetris/Game.jsAdded+301
filestorage/gd/tetris/Game_Logic.jsAdded+209
filestorage/gd/tetris/PreviewGroup.jsAdded+47
filestorage/gd/tetris/README.mdAdded+15
filestorage/gd/tetris/RandomBag.jsAdded+49
filestorage/gd/tetris/ScoreTracker.jsAdded+213
filestorage/gd/tetris/Shapes.jsAdded+94
filestorage/gd/tetris/TtyBlock.jsAdded+84
filestorage/gd/tetris/controls.jsAdded+202
filestorage/gd/tetris/cookie.jsAdded+24
filestorage/gd/tetris/highScores.htmlAdded+62
filestorage/gd/tetris/highScores.jsAdded+39
filestorage/gd/tetris/index.htmlAdded+43
filestorage/gd/tetris/json-minified.jsAdded+4
filestorage/gd/tetris/scoreScreen.htmlAdded+71
filestorage/gd/tetris/scoreScreen.jsAdded+88
filestorage/gd/tetris/styles.cssAdded+289
filestorage/gd/tetris/tetris.jsAdded+249