Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
5cc1c6e6
Commit
5cc1c6e6
authored
3 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: #fe attach foes to scene
parent
ed6e536c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/js/fight_scene.js
+8
-13
8 additions, 13 deletions
frontend/src/js/fight_scene.js
frontend/src/js/foe.js
+5
-5
5 additions, 5 deletions
frontend/src/js/foe.js
with
13 additions
and
18 deletions
frontend/src/js/fight_scene.js
+
8
−
13
View file @
5cc1c6e6
import
Phaser
from
"
phaser
"
;
import
enemy
from
"
./
enemy
"
;
import
Foe
from
"
./
foe
"
;
import
backend
from
"
./backend
"
;
import
levenshtein
from
"
damerau-levenshtein
"
;
const
fightScene
=
new
Phaser
.
Scene
(
"
fight
"
);
let
onscreenEnemies
=
[];
window
.
onscreenEnemies
=
onscreenEnemies
;
fightScene
.
foes
=
[];
fightScene
.
preload
=
preload
;
fightScene
.
create
=
create
;
...
...
@@ -217,7 +215,7 @@ function initAndBindGuessPreview(scene) {
event
.
keyCode
===
Phaser
.
Input
.
Keyboard
.
KeyCodes
.
ENTER
&&
textEntry
.
text
.
length
>
0
)
{
submitTranscription
(
textEntry
.
text
);
submitTranscription
(
textEntry
.
text
,
scene
);
textEntry
.
text
=
textEntry
.
text
.
substr
(
0
,
0
);
}
});
...
...
@@ -256,7 +254,7 @@ function shootSpear(enemy, hit, scene = fightScene) {
message
.
destroy
();
});
// TODO: ew.
window
.
onscreenEnemies
.
splice
(
window
.
onscreenEnemi
es
.
indexOf
(
enemy
),
1
);
scene
.
foes
.
splice
(
scene
.
fo
es
.
indexOf
(
enemy
),
1
);
}
let
curve
=
new
Phaser
.
Curves
.
QuadraticBezier
(
...
...
@@ -327,13 +325,13 @@ function shootSpear(enemy, hit, scene = fightScene) {
spear
.
anims
.
play
(
"
spearAni
"
);
}
function
submitTranscription
(
transcription
)
{
if
(
window
.
onscreenEnemi
es
.
length
<
1
)
return
;
function
submitTranscription
(
transcription
,
scene
)
{
if
(
scene
.
fo
es
.
length
<
1
)
return
;
let
similarity
=
0
;
let
match
=
null
;
window
.
onscreenEnemi
es
.
forEach
((
foe
)
=>
{
scene
.
fo
es
.
forEach
((
foe
)
=>
{
const
s
=
levenshtein
(
transcription
.
toLowerCase
(),
foe
.
word
.
ocr_transcript
.
toLowerCase
(),
...
...
@@ -368,11 +366,8 @@ function gameStart(scene) {
}
function
dispatchEnemy
(
scene
)
{
let
e
=
new
enemy
(
scene
);
window
.
onscreenEnemies
.
push
(
e
);
backend
.
post
(
"
GetImage
"
,
{}).
then
(
function
(
response
)
{
e
.
word
=
response
.
data
;
let
e
=
new
Foe
(
scene
,
response
.
data
)
;
scene
.
textures
.
addBase64
(
`WORD-
${
response
.
data
.
id
}
`
,
response
.
data
.
image
);
scene
.
textures
.
once
(
...
...
This diff is collapsed.
Click to expand it.
frontend/src/js/
enemy
.js
→
frontend/src/js/
foe
.js
+
5
−
5
View file @
5cc1c6e6
let
enemies
=
[
"
bear
"
,
"
wolf
"
,
"
deer
"
,
"
boar
"
];
let
enemiesSpeed
=
50000
;
class
enemy
{
word
=
null
;
constructor
(
scene
)
{
class
Foe
{
constructor
(
scene
,
word
)
{
this
.
scene
=
scene
;
this
.
scene
.
foes
.
push
(
this
);
this
.
word
=
word
;
}
run
(
callback
)
{
...
...
@@ -72,4 +72,4 @@ function setAnimation(obj, idleKey) {
obj
.
play
({
key
:
idleKey
,
repeat
:
-
1
});
}
export
default
enemy
;
export
default
Foe
;
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