Skip to content
Snippets Groups Projects
Verified Commit 380908a9 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Instantiate backend and game and link properly

parent 88ebc23c
No related branches found
No related tags found
No related merge requests found
Pipeline #7276 failed
class BaseBackend() {
}
export default BaseBackend;
import BaseBackend from './base';
import WidgetApi from 'matrix-widget-api';
class WidgetBackend {
const eventNamespace = 'team.auglement.augmentile';
const EventTypes = {
map: eventNamespace + '.map',
player: eventNamepsace + '.player'
}
class WidgetBackend extends BaseBackend {
constructor(widgetId, userId) {
this.api = new WidgetApi(widgetId);
this.requestCapabilities();
this.api.star();
}
requestCapabilities() {
this.api.requestCapabilityToReceiveState(EventTypes.map);
this.api.requestCapabilityToReceiveState(EventTypes.player);
this.api.requestCapabilityToSendState(EventTypes.player);
}
set game(value) {
this.api.setContentLoaded();
}
}
export default WidgetBackend;
......@@ -2,7 +2,7 @@ import Phaser from 'phaser';
import TestScene from './scenes/test';
class Game {
constructor(width, height) {
constructor(width, height, backend) {
this.config = {
type: Phaser.AUTO,
width: width,
......@@ -11,6 +11,9 @@ class Game {
};
this.game = new Phaser.Game(this.config);
this.backend = backend;
this.backend.game = this;
}
}
......
import WidgetBackend from './backends/widget';
import Game from './frontend/game';
const urlParams = new URLSearchParams(window.location.search);
const widgetId = urlParams.get('widgetId');
const userId = urlParams.get('userId');
const width = 800;
const height = 600;
let game = new Game(width, height);
let backend = new WidgetBackend(widgetId, userId);
let game = new Game(width, height, backend);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment