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

4
var stage, provider;
Alexander Bazo committed
5

6
function init(options) {
7
  Logger.log("Starting StarGazer game", "Game");
8 9
  stage = options.canvas;
  GameManager.init(stage);
10
  GameManager.start();
11
  provider = options.gazeDataProvider;
12 13
  provider.addEventListener("dataavailable", onGazeUpdate);
}
Alexander Bazo committed
14

15 16
function onGazeUpdate(event) {
  let gazePoint = event.data;
17
  gazePoint.linkTo(stage);
18
  if (gazePoint.hasLink) {
19
    GameManager.addGazePoint(gazePoint);
Alexander Bazo committed
20
  }
Alexander Bazo committed
21 22
}

23 24 25
export default {
  init: init,
};