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

4
var canvas, provider;
Alexander Bazo committed
5

6
function init(options) {
7
  Logger.log("Starting StarGazer game", "Game");
8
  canvas = options.canvas;
9
  GameManager.setOptions({
10 11 12 13 14 15 16
    canvas: canvas,
    frameRate: options.fps,
    version: options.version,
    debug: options.showDebug,
    width: options.width,
    height: options.height,
  });
17
  GameManager.start();
18
  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
    GameManager.addGazePoint(gazePoint);
Alexander Bazo committed
27
  }
Alexander Bazo committed
28 29
}

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