Source: app02a/app.js

/**
 * @author    Wolfgang Kowarschick <kowa@hs-augsburg.de>
 * @copyright 2017 - 2018
 * @license   CC-BY-NC-SA-4.0
 */

/**
 * @module app02a/app
 */

import                             '/css/app.css';
import wait                   from '/wk/util/wait';
import GameLoop               from '/wk/game/GameLoop';
import {Application}          from 'pixi.js';

import config                 from './config/config.json';
import concretize             from '/wk/config/concretize';

import ModelStage             from './model/ModelStage';
import ModelCircle            from './model/ModelCircle';
import {initUpdater, update}  from './model/update';

import ViewCircle             from './view/ViewCircle';
import {initRenderer, render} from './view/render';

const
  c_view_stage
    = document.getElementById('stage'),

  c_pixi_app =
    new Application
        ( document.documentElement.clientWidth,
          document.documentElement.clientHeight,
          { transparent: true,
            view:        c_view_stage
          }
        ),
  
  c_model_stage =
    new ModelStage(concretize
                   ({config:      config.model.stage,
                     environment:
                     { '@right':  document.documentElement.clientWidth,
                       '@bottom': document.documentElement.clientHeight
                     }
                   })
                  ),
  
  c_model_ball =
    new ModelCircle(config.model.ball),
  
  c_view_ball =
    new ViewCircle(c_pixi_app, c_model_ball, config.view.ball);

initUpdater({stage: c_model_stage, circle: c_model_ball});
initRenderer([c_view_ball]);

async function init()
{ c_view_stage.classList.remove('hidden');
  await wait(500);
  new GameLoop({update: update, render: render}).start();
}

window.addEventListener('load', init);