diff --git a/assets/cover.ase b/assets/cover.ase new file mode 100644 index 0000000..e1e8abe Binary files /dev/null and b/assets/cover.ase differ diff --git a/assets/cover.png b/assets/cover.png new file mode 100644 index 0000000..e4aa9f5 Binary files /dev/null and b/assets/cover.png differ diff --git a/build.js b/build.js index baa61ee..5348b1b 100644 --- a/build.js +++ b/build.js @@ -12,6 +12,10 @@ const fs = require("fs-extra"), VERSION_PLACEHOLDER = "$VERSION", version = require("./package.json").version, fileList = [{ + url: "https://raw.githubusercontent.com/colyseus/colyseus.js/master/dist/colyseus.js", + localPath: "build/vendors/colyseus.js", + }, + { url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.js", localPath: "build/vendors/gazeclient.js", }, diff --git a/index.html b/index.html index 03d1a53..e9114d6 100644 --- a/index.html +++ b/index.html @@ -31,6 +31,7 @@ + diff --git a/package-lock.json b/package-lock.json index 36e4f66..689d05a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "stargazer", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/resources/js/com/NetClient.js b/resources/js/com/NetClient.js new file mode 100644 index 0000000..9fd410e --- /dev/null +++ b/resources/js/com/NetClient.js @@ -0,0 +1,40 @@ +const DEFAULT_GAME_ROOM = "star_gazer_lab"; + +class NetClient { + + connect(url) { + this.client = new Colyseus.Client('ws://localhost:2567'); + } + + joinGame() { + this.client.joinOrCreate(DEFAULT_GAME_ROOM).then(this.onConnect.bind(this)).catch( + this.onError.bind(this)); + } + + onConnect(room) { + console.log(room.sessionId, "joined", room.name); + room.onStateChange(this.onUpdate); + room.onMessage(this.onMessage); + room.onError(this.onError); + room.onLeave(this.onLeave); + } + + onUpdate(state) { + console.log("received new state from server"); + console.log(state); + } + + onMessage(message) { + console.log("Received new message from server") + } + + onError(error) { + console.log(error); + } + + onLeave() { + console.log("Client left room") + } +} + +export default NetClient; \ No newline at end of file diff --git a/resources/js/game/objects/GameObject.js b/resources/js/game/objects/GameObject.js index e68e38d..77cc087 100644 --- a/resources/js/game/objects/GameObject.js +++ b/resources/js/game/objects/GameObject.js @@ -33,8 +33,6 @@ class GameObject { return Math.sqrt(deltaX * deltaX + deltaY * deltaY); } - draw(context) {} - } export default GameObject; \ No newline at end of file diff --git a/resources/js/index.js b/resources/js/index.js index c3180a4..881f1ac 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -3,6 +3,7 @@ import Logger from "./utils/Logger.js"; import StarGazer from "./game/StarGazer.js"; import FakeGazeDataProvider from "./gaze/FakeGazeDataProvider.js"; import GazeDataProvider from "./gaze/GazeDataProvider.js"; +import NetClient from "./com/NetClient.js"; var canvas = document.querySelector("canvas"), starScreen = document.querySelector("#startScreen"); @@ -14,8 +15,7 @@ function init() { } document.querySelector("#versionInfo").innerHTML = `build ${GameConfig.getVersion()}`; - document.querySelector("#startButton").addEventListener("click", - prepareGame); + document.querySelector("#startButton").addEventListener("click", prepareGame); } function loadOptions() { @@ -27,6 +27,13 @@ function loadOptions() { GameConfig.setShowVerboseDebugInfoInConsole(logToConsole); } +function testServer() { + console.log("Testing Server ..."); + let client = new NetClient(); + client.connect("ws://localhost:2567"); + client.joinGame(); +} + function prepareGame() { loadOptions(); StarGazer.init({