Source: app01a/model/Updater.js

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

/**
 * @module app01a/model/Updater
 */

import collisionCircleStage from './collisionCircleStage';

/**
 * @property {ModelStage|Object}  stage
 *           the stage to be used for collision detection and handling
 * @property {ModelCircle|Object} circle
 *           the circle to be updated and tested for colliding with the stage
 */
class Updater
{ /**
   * @param {Object}             p_config
   * @param {ModelStage|Object}  p_config.stage
   * @param {ModelCircle|Object} p_config.ball
   */
  constructor({stage: p_stage, ball: p_ball})
  { this.stage = p_stage;
    this.ball  = p_ball;

    // As the function "update" is used as a callback function,
    // it is defined as an arrow function.
    // As EcmaScript class definitions don't support arrow function yet,
    // they are defined here.
    this.update =
      (p_delta_s) => { p_ball.update(p_delta_s);
                       collisionCircleStage(this.ball, this.stage);
                     };
  }
}

export default Updater;