<commit_before>/**
 * game.js
 *
 * This module houses the high-level instantiation and event binding for the
 * entire game. If interfaces need to be exposes to the global scope or parent
 * namespace, it should be done so in this module.
 */

define('game',

['Canvas', 'Player', 'vent', 'util'],

function( Canvas, Player, vent, util ){

    'use strict';

    var canvas,
        player,
        game;

    // Create the canvas stage that we'll be using for primary game entities
    canvas = new Canvas('main', {
        width: 800,
        height: 600,
        bgColor: "#000"
    });

    // Create the player entity
    player = new Player(canvas);

    // Create an object we can expose as an interface for debugging
    // (modules shouldn't be touch this object)
    game = {
        canvas: canvas,
        player: player
    };

    // Couple DOM events to our custom event emitter
    document.addEventListener('keydown', function( ev ){
        vent.emit('keydown', ev);
    });
    document.addEventListener('keyup', function( ev ){
        vent.emit('keyup', ev);
    });
    document.addEventListener('DOMContentLoaded', function(){
        vent.emit('create', game);
        vent.emit('start', game);
    });
    util.getById('game-container').addEventListener('mousemove', function( ev ){
        vent.emit('mousemove', ev, canvas.elem);
    });
    document.addEventListener('click', function( ev ){
        vent.emit('click', ev);
    });

    // Expose the interface
    window.game = game;

    return game;

});<commit_msg>subscribe to event which can expose private APIs<commit_after>/**
 * game.js
 *
 * This module houses the high-level instantiation and event binding for the
 * entire game. If interfaces need to be exposes to the global scope or parent
 * namespace, it should be done so in this module.
 */

define('game',

['Canvas', 'Player', 'vent', 'util'],

function( Canvas, Player, vent, util ){

    'use strict';

    var canvas,
        player,
        game;

    // Create the canvas stage that we'll be using for primary game entities
    canvas = new Canvas('main', {
        width: 800,
        height: 600,
        bgColor: "#000"
    });

    // Create the player entity
    player = new Player(canvas);

    // Create an object we can expose as an interface for debugging
    // (modules shouldn't be touch this object)
    game = {
        canvas: canvas,
        player: player,
        vent: vent
    };

    // Couple DOM events to our custom event emitter
    document.addEventListener('keydown', function( ev ){
        vent.emit('keydown', ev);
    });
    document.addEventListener('keyup', function( ev ){
        vent.emit('keyup', ev);
    });
    document.addEventListener('DOMContentLoaded', function(){
        vent.emit('create', game);
        vent.emit('start', game);
    });
    util.getById('game-container').addEventListener('mousemove', function( ev ){
        vent.emit('mousemove', ev, canvas.elem);
    });
    document.addEventListener('click', function( ev ){
        vent.emit('click', ev);
    });

    // Expose the interface
    window.game = game;

    vent.on('publicize', function( namespace, obj ){
        window.game[namespace] = obj;
    });

    return game;

});
{'fraction_non_alphanumeric': 0.13134420178406644, 'fraction_numerical': 0.005536757920639803, 'mean_word_length': 2.5973451327433628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6663163', 'n_tokens_mistral': 917, 'n_tokens_neox': 870, 'n_words': 303}