Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
StarGazer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
85a592f2
authored
5 years ago
by
Alexander Bazo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fps counter
parent
512fc907
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
resources/js/game/GameManager.js
+14
-1
No files found.
resources/js/game/GameManager.js
View file @
85a592f2
...
...
@@ -3,6 +3,7 @@ import Logger from "../utils/Logger.js";
const
BACKGROUND_COLOR
=
"rgba(30,30,30,0.5)"
,
DEFAULT_GAZE_POINT_RADIUS
=
10
,
DEFAULT_GAZE_POINT_COLOR
=
"#ff007b"
,
FPS_COLOR
=
"#ffbb00"
,
MAX_GAZE_POINT_AGE
=
500
;
var
lastUpdate
,
...
...
@@ -58,6 +59,7 @@ class GameManger {
this
.
updateGazePoints
();
this
.
context
.
clearRect
(
0
,
0
,
this
.
canvas
.
width
,
this
.
canvas
.
height
);
this
.
drawGazePoints
();
this
.
drawFrameRate
();
this
.
setUpdateTime
();
}
...
...
@@ -76,7 +78,8 @@ class GameManger {
this
.
context
.
fillStyle
=
DEFAULT_GAZE_POINT_COLOR
;
for
(
let
item
of
this
.
gazePoints
)
{
this
.
context
.
save
();
this
.
context
.
globalAlpha
=
1
-
(
now
-
item
[
1
].
createdAt
)
/
MAX_GAZE_POINT_AGE
;
this
.
context
.
globalAlpha
=
1
-
(
now
-
item
[
1
].
createdAt
)
/
MAX_GAZE_POINT_AGE
;
this
.
context
.
beginPath
();
this
.
context
.
ellipse
(
item
[
1
].
targetX
,
item
[
1
].
targetY
,
DEFAULT_GAZE_POINT_RADIUS
,
DEFAULT_GAZE_POINT_RADIUS
,
Math
.
PI
/
4
,
...
...
@@ -87,6 +90,15 @@ class GameManger {
}
}
drawFrameRate
()
{
let
fps
=
1000
/
lastDelta
;
this
.
context
.
beginPath
();
this
.
context
.
font
=
"30px Arial"
;
this
.
context
.
fillStyle
=
FPS_COLOR
;
this
.
context
.
fillText
(
`FPS:
${
fps
}
`
,
20
,
20
);
this
.
context
.
closePath
();
}
}
export
default
GameManger
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment