StarGazer.js 739 Bytes
Newer Older
Alexander Bazo committed
1 2
import Logger from "../utils/Logger.js";
import GameManager from "./GameManager.js";
3
import GameRenderer from "./GameRenderer.js";
Alexander Bazo committed
4

5
var canvas, provider;
Alexander Bazo committed
6

7
function init(options) {
8
  Logger.log("Starting StarGazer game");
9 10 11 12 13 14 15 16 17 18
  canvas = options.canvas;
  GameRenderer.start({
    canvas: canvas,
    frameRate: options.fps,
    version: options.version,
    debug: options.showDebug,
    width: options.width,
    height: options.height,
  });
  provider = options.gazeDataProvider;
19 20
  provider.addEventListener("dataavailable", onGazeUpdate);
}
Alexander Bazo committed
21

22 23 24 25
function onGazeUpdate(event) {
  let gazePoint = event.data;
  gazePoint.linkTo(canvas);
  if (gazePoint.hasLink) {
26
    GameRenderer.addGazePoint(gazePoint);
Alexander Bazo committed
27
  }
Alexander Bazo committed
28 29
}

30 31 32
export default {
  init: init,
};