/** @license * * SURVIVOR: A HTML + CSS + JavaScript prototype * based on the Commodore 64 version of Survivor from 1983 * ------------------------------------------------------- * http://schillmania.com/survivor/ * http://www.schillmania.com/content/entries/2012/survivor-c64-html-remake/ * http://www.flickr.com/photos/schill/sets/72157628885315581/ * https://github.com/scottschiller/SURVIVOR * * Scott Schiller wrote this beginning in December 2011, while on a plane to Hawaii. * Code provided under the Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0) License: * http://creativecommons.org/licenses/by-nc/3.0/ * */ // 7.02.2018: Move to appeasing the eslint gods. Prevent HTML5 Audio() on Safari because performance dies. CSS clean-up, -webkit- prefix cruft clean-up etc. // 8.16.2014: The jslint gods have been re-appeased. Added strict mode. // 5.25.2013: The jslint gods have been appeased. /*global window, console, document, navigator, setTimeout, setInterval, clearInterval, soundManager */ /** * * The TODO: list (written on an old laptop while on a plane to Hawaii, 12/21/2011) * -------------------------------------------------------------------------------- * * Map (grid) of space * ------------------- * * Main UI * ------- * - ship always in center * - inertia? some inertia. * - slight parallax on background stars? maybe a blur/streak effect? why not. * - fixed screen size, center or no? * - fixed grid item size? 20x20px? * - world should be able to wrap around. Draw in tiles? * - debug mode should show outlines, overlays, collision detection etc. in CSS. * * Collision detection * ------------------- * - player vs. bricks, bad guys, gunfire (= death) * - x/y + vector -> row/col? player can occupy potentially 4 grid spaces at once with overlap? * - when in a row/column, determine exactly what is in contact. isOverlappingGrid({x, y, row, col}) or somesuch. * - spaceballs should reverse course and randomly flip the other axis when they hit a boundary (wall, or another spaceball.) * - bad guys only collide with spaceship. absolutely-positioned for everything else. * * Graphic elements * ---------------- * - blocks * - "bases" (structures which hold turrets) * - turrets themselves * - turret gunfire * - bad guys * - spaceballs * * Things that move, object collision etc. * --------------------------------------- * - blocks (can be shot, disappear) * - bad guys * - spaceballs (immune to shots, move randomly) * - turret gunfire * * Sound effects * ------------- * - welcome screen "flight of the valkyries" music? * - initial game start / "warp" sound * - spaceship thrust * - bad guy cartoon noises (one per bad guy? simultaneous allowed?) * - bad guy single-frozen-note death sound * - box shot/popping sounds (incremental sounds?) * - ship explosion noise * - base explosion (60 Hz, louder, BOOM) sound * - background pulse noise set to "frame rate" of level * * UI considerations * ----------------- * - mobile, iOS: No sound, or single-channel sound hack? * - touch controls - finger on screen = direction? circle-based joystick UI? * - touch controls - fire button, smartbomb button? * * Game logic * ---------- * - intro screen, retro font etc.? * - ability to choose start level? * - begin game: startGame({ level: x, lives: y, smartbombs: z }); ? * - points/scoring? who cares? * - level finished animation sequence - large explosions, show next "level X" screen etc. * * BEHAVIOURS * ---------- * - gunfire * + from turret, fixed target distance and speed * + once target is reached, fires again (any delay?) * + collides only with spaceship * - base * + explodes once all turrets are shot out * + noise, animation, increases points, increases game speed(?) * - spaceballs * + wander aimlessly around the world * + bounce off walls and each other * + collision logic: see above, or spaceship (death) * + absorb spaceship fire? turret gunfire? * - bad guys * + show up at random intervals, depending on level/difficulty? * + start randomly off-screen, seek out player * + jittery motion (animation) and movement * + bird, face, "X", ? * - squares/boxes ("building blocks") * + form walls around bases * + worth some points(?) * + take two hits * + increase global "box pop" sound when hit, eventually resets * + collide with spaceship, kill on contact * + a few different box designs * + up to 4 frames of animation */ var survivor; (function(window) { 'use strict'; if (window.console === undefined) { // hax window.console = { log: function() { return false; } }; } var IS_MUTED = window.location.href.toString().match(/mute/i); var winloc = window.location.toString(); /** * Safari performance dies when playing multiple HTML5