<commit_before>'use strict';

const PIXI = require("pixi.js");
const Renderer = require('incheon').render.Renderer;
let Missile = require('../common/Missile');
let Ship = require('../common/Ship');

const ASSETPATH = {
    ship: "assets/ship1.png",
    missile: "assets/shot.png"
};

/**
 * Renderer for the Spaaace client - based on Pixi.js
 */
class SpaaaceRenderer extends Renderer {

    constructor(gameEngine) {
        super(gameEngine);
        this.sprites = {};
        this.isReady = false;
    }

    init() {

        this.stage = new PIXI.Container();
        this.renderer = PIXI.autoDetectRenderer(this.gameEngine.worldSettings.width, this.gameEngine.worldSettings.height);
        document.body.appendChild(this.renderer.view);

        PIXI.loader.add([
                ASSETPATH.ship,
                ASSETPATH.missile
            ])
            .load(() => {this.isReady = true;});
    }

    draw() {
        super.draw();
        if (!this.isReady) return; //assets might not have been loaded yet

        for (let objId of Object.keys(this.sprites)) {
            if (this.gameEngine.world.objects[objId]) {
                this.sprites[objId].x = this.gameEngine.world.objects[objId].x;
                this.sprites[objId].y = this.gameEngine.world.objects[objId].y;
                this.sprites[objId].rotation = this.gameEngine.world.objects[objId].angle * Math.PI/180;
            } else {<commit_msg>Renderer: add renderer after DOM loaded<commit_after>'use strict';

const PIXI = require("pixi.js");
const Renderer = require('incheon').render.Renderer;
let Missile = require('../common/Missile');
let Ship = require('../common/Ship');

const ASSETPATH = {
    ship: "assets/ship1.png",
    missile: "assets/shot.png"
};

/**
 * Renderer for the Spaaace client - based on Pixi.js
 */
class SpaaaceRenderer extends Renderer {

    constructor(gameEngine) {
        super(gameEngine);
        this.sprites = {};
        this.isReady = false;
    }

    init() {
        this.stage = new PIXI.Container();
        this.renderer = PIXI.autoDetectRenderer(this.gameEngine.worldSettings.width, this.gameEngine.worldSettings.height);
        document.addEventListener("DOMContentLoaded", ()=>{ document.body.appendChild(this.renderer.view); });

        PIXI.loader.add([
                ASSETPATH.ship,
                ASSETPATH.missile
            ])
            .load(() => {this.isReady = true;});
    }

    draw() {
        super.draw();
        if (!this.isReady) return; //assets might not have been loaded yet

        for (let objId of Object.keys(this.sprites)) {
            if (this.gameEngine.world.objects[objId]) {
                this.sprites[objId].x = this.gameEngine.world.objects[objId].x;
                this.sprites[objId].y = this.gameEngine.world.objects[objId].y;
                this.sprites[objId].rotation = this.gameEngine.world.objects[objId].angle * Math.PI/180;
            } else {
{'fraction_non_alphanumeric': 0.14232209737827714, 'fraction_numerical': 0.002723867892407218, 'mean_word_length': 2.4044032444959442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6248967', 'n_tokens_mistral': 913, 'n_tokens_neox': 885, 'n_words': 162}