Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Augmentile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Auglement
Augmentile
Commits
380908a9
Verified
Commit
380908a9
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
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
3 years ago
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/backends/base.js
+4
-0
4 additions, 0 deletions
src/backends/base.js
src/backends/widget.js
+24
-1
24 additions, 1 deletion
src/backends/widget.js
src/frontend/game.js
+4
-1
4 additions, 1 deletion
src/frontend/game.js
src/widget.js
+6
-1
6 additions, 1 deletion
src/widget.js
with
38 additions
and
3 deletions
src/backends/base.js
0 → 100644
+
4
−
0
View file @
380908a9
class
BaseBackend
()
{
}
export
default
BaseBackend
;
This diff is collapsed.
Click to expand it.
src/backends/widget.js
+
24
−
1
View file @
380908a9
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
;
This diff is collapsed.
Click to expand it.
src/frontend/game.js
+
4
−
1
View file @
380908a9
...
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/widget.js
+
6
−
1
View file @
380908a9
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
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment