function Game()

in application/game/js/alienattack.js [60:141]


function Game() {

    this.PUBLISHING_INTERVAL = 300; // publish state at each 300ms; This can be set free when we implement kinesis autoscaling
    this.publishingInterval = null;

    this.awsfacade = new AWSFacade(AWS_CONFIG);
    this.session = null;

    // Check internet connection state
    this.isConnected = true;

    // This will be useful when the webso
    this.websocketEnabled = false;

    // Cleaning sessionStorage
    if (typeof (Storage) !== "undefined") {
       sessionStorage.clear();
    } else {
        console.log('No support for local storage');
    }

    // scorestate
    this.scorestate = new ScoreState();

    // load sprite
    this.invaderImg = new Sprite('./../images/invader1.png', 1, 2);
    this.shipImg = new Sprite('./../images/ship.png', 1, 2);

    //  Set the initial config.
    this.config = {
        bombRate: 0.05,
        bombMinVelocity: 50,
        bombMaxVelocity: 50,
        invaderInitialVelocity: 25,
        invaderAcceleration: 0,
        invaderDropDistance: 20,
        rocketVelocity: 120,
        rocketMaxFireRate: 2,
        gameWidth: 400,
        gameHeight: 300,
        fps: 50,
        debugMode: false,
        invaderRanks: 5,
        invaderFiles: 10,
        shipSpeed: 120,
        levelDifficultyMultiplier: 0.2,
        pointsPerInvader: 5
    };

    //  All state is in the variables below.
    this.username = null;
    this.width = 0;
    this.height = 0;
    this.gameBounds = { left: 0, top: 0, right: 0, bottom: 0 };
    this.intervalId = 0;
    this.lives = 3;    
    this.score = 0;
    this.level = 1;
    this.shots = 0;

    //  The state stack.
    this.stateStack = [];

    //  Input/output
    this.pressedKeys = {};
    this.gameCanvas = null;

    //  All sounds.
    this.sounds = null;
    this.isMute = false;

    // Not logged in
    this.loggedin = false;

    // Indicates that the user wants to register or login
    // If the user closes the register-or-login window
    // then he just plays
    this.userWantsRegisterOrLogin = true;
    this.userWantsToRegister = true; //let's replace previous variable
    this.userWantsToLogin = true; //let's replace previous variable
    window.addEventListener("unload", this.onbeforeunload.bind(this));
}