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
b636d01c
"...Parameters/BigAgentive2NonAgentive2-Random-3vs1_100_.txt" did not exist on "57bc6ce70c20e0ffc93cb8f60376dac0bb56c33e"
Commit
b636d01c
authored
3 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
feat: #fe mae HUD configurable via constructor
parent
738ed2ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/js/hud.ts
+45
-14
45 additions, 14 deletions
frontend/src/js/hud.ts
with
45 additions
and
14 deletions
frontend/src/js/hud.ts
+
45
−
14
View file @
b636d01c
...
...
@@ -4,35 +4,45 @@ const ICONS = {
HEALTH
:
"
❤️️
"
,
};
const
STATS_TEXT_STYLE
=
{
const
STATS_
BASE_
TEXT_STYLE
=
{
fontFamily
:
"
Courier
"
,
fontStyle
:
"
bold
"
,
fontSize
:
"
max(3vw,20px)
"
,
// never smaller than 20px
color
:
"
white
"
,
testString
:
`
${
ICONS
.
CLOCK
}${
ICONS
.
HEALTH
}${
ICONS
.
SCORE
}
1234567890:.`
,
stroke
:
"
black
"
,
strokeThickness
:
4
,
}
as
Phaser
.
Types
.
GameObjects
.
Text
.
TextStyle
;
const
INPUT_TEXT_STYLE
=
{
const
INPUT_
BASE_
TEXT_STYLE
=
{
fontFamily
:
"
Courier
"
,
fontStyle
:
"
bold
"
,
fontSize
:
"
min(12vw,60px)
"
,
// always fit ~12 chars comfortably in width
color
:
"
white
"
,
testString
:
`ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖẞabcdefghijklmnopqrstuvwxyzäüöß `
,
}
as
Phaser
.
Types
.
GameObjects
.
Text
.
TextStyle
;
interface
HudOptions
{
statsPadding
:
number
;
statsFontSize
:
string
;
inputPosition
:
number
;
inputFontSize
:
string
;
}
export
default
class
HUD
{
scene
:
Phaser
.
Scene
;
options
:
HudOptions
;
input
:
Phaser
.
GameObjects
.
Text
;
score
:
Phaser
.
GameObjects
.
Text
;
clock
:
Phaser
.
GameObjects
.
Text
;
health
:
Phaser
.
GameObjects
.
Text
;
pad
:
number
;
constructor
(
scene
:
Phaser
.
Scene
)
{
constructor
(
scene
:
Phaser
.
Scene
,
options
?:
HudOptions
)
{
this
.
scene
=
scene
;
this
.
pad
=
Math
.
min
(
this
.
scene
.
cameras
.
main
.
width
*
0.01
,
10
);
// min(1vw,10px)
this
.
options
=
options
||
{
statsPadding
:
Math
.
min
(
this
.
scene
.
cameras
.
main
.
width
*
0.01
,
10
),
// min(1vw,10px)
statsFontSize
:
"
max(3vw,20px)
"
,
// never smaller than 20px
inputPosition
:
0.5
,
inputFontSize
:
"
min(12vw,60px)
"
,
// always fit ~12 chars comfortably in width
};
this
.
input
=
this
.
initInput
(
scene
);
this
.
score
=
this
.
initScore
(
scene
);
this
.
health
=
this
.
initHealth
(
scene
);
...
...
@@ -43,22 +53,42 @@ export default class HUD {
return
scene
.
add
.
text
(
scene
.
cameras
.
main
.
width
/
2
,
scene
.
cameras
.
main
.
height
/
2
,
scene
.
cameras
.
main
.
height
*
this
.
options
.
inputPosition
,
""
,
INPUT_TEXT_STYLE
,
{
...
INPUT_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
inputFontSize
,
},
)
.
setOrigin
(
0.5
,
0.5
);
}
statsTextStyle
()
{
return
{
...
STATS_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
statsFontSize
,
};
}
initScore
(
scene
:
Phaser
.
Scene
)
{
return
scene
.
add
.
text
(
this
.
pad
,
this
.
pad
,
""
,
STATS_TEXT_STYLE
)
.
text
(
this
.
options
.
statsPadding
,
this
.
options
.
statsPadding
,
""
,
this
.
statsTextStyle
(),
)
.
setOrigin
(
0
,
0
);
}
initHealth
(
scene
:
Phaser
.
Scene
)
{
return
scene
.
add
.
text
(
scene
.
cameras
.
main
.
width
-
this
.
pad
,
this
.
pad
,
""
,
STATS_TEXT_STYLE
)
.
text
(
scene
.
cameras
.
main
.
width
-
this
.
options
.
statsPadding
,
this
.
options
.
statsPadding
,
""
,
this
.
statsTextStyle
(),
)
.
setOrigin
(
1
,
0
);
}
...
...
@@ -66,9 +96,9 @@ export default class HUD {
return
scene
.
add
.
text
(
scene
.
cameras
.
main
.
width
*
0.5
,
this
.
pad
,
this
.
options
.
statsPadding
,
`
${
ICONS
.
CLOCK
}
1:23.32`
,
STATS_TEXT_STYLE
,
this
.
statsTextStyle
()
,
)
.
setOrigin
(
0.5
,
0
);
}
...
...
@@ -105,7 +135,8 @@ export default class HUD {
this
.
scene
.
cameras
.
main
.
height
/
2
,
input
,
{
...
INPUT_TEXT_STYLE
,
...
INPUT_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
inputFontSize
,
color
:
color
,
},
)
...
...
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