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
9064e309
authored
Aug 27, 2019
by
Alexander Bazo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fps display
parent
85a592f2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
resources/js/game/GameManager.js
+13
-3
resources/js/game/GazePoint.js
+1
-1
resources/js/game/StarGazer.js
+4
-1
resources/js/index.js
+3
-1
No files found.
resources/js/game/GameManager.js
View file @
9064e309
...
...
@@ -25,6 +25,14 @@ class GameManger {
this
.
fps
=
fps
;
}
showFPS
()
{
this
.
shouldDisplayFrameRate
=
true
;
}
hideFPS
()
{
this
.
shouldDisplayFrameRate
=
false
;
}
setSize
(
width
,
height
)
{
this
.
canvas
.
width
=
width
;
this
.
canvas
.
height
=
height
;
...
...
@@ -59,7 +67,9 @@ class GameManger {
this
.
updateGazePoints
();
this
.
context
.
clearRect
(
0
,
0
,
this
.
canvas
.
width
,
this
.
canvas
.
height
);
this
.
drawGazePoints
();
if
(
this
.
shouldDisplayFrameRate
===
true
)
{
this
.
drawFrameRate
();
}
this
.
setUpdateTime
();
}
...
...
@@ -91,11 +101,11 @@ class GameManger {
}
drawFrameRate
()
{
let
fps
=
1000
/
lastDelta
;
let
fps
=
parseInt
(
1000
/
lastDelta
)
;
this
.
context
.
beginPath
();
this
.
context
.
font
=
"
3
0px Arial"
;
this
.
context
.
font
=
"
2
0px Arial"
;
this
.
context
.
fillStyle
=
FPS_COLOR
;
this
.
context
.
fillText
(
`FPS:
${
fps
}
`
,
20
,
2
0
);
this
.
context
.
fillText
(
`FPS:
${
fps
}
`
,
30
,
3
0
);
this
.
context
.
closePath
();
}
...
...
resources/js/game/GazePoint.js
View file @
9064e309
...
...
@@ -3,7 +3,7 @@ class GazePoint {
constructor
(
screenX
,
screenY
,
createdAt
,
id
)
{
this
.
screenX
=
screenX
;
this
.
screenY
=
screenY
;
this
.
createdAt
=
createdAt
;
this
.
createdAt
=
Date
.
now
()
;
this
.
id
=
id
||
this
.
createdAt
;
}
...
...
resources/js/game/StarGazer.js
View file @
9064e309
...
...
@@ -11,13 +11,16 @@ class StarGazer {
gm
=
new
GameManager
();
gm
.
setCanvas
(
canvas
);
gm
.
setFrameRate
(
config
.
fps
);
if
(
config
.
showFPS
===
true
)
{
gm
.
showFPS
();
}
gm
.
setSize
(
config
.
width
,
config
.
height
);
gm
.
start
();
}
onGazeUpdate
(
gazePoint
)
{
gazePoint
.
linkTo
(
canvas
);
if
(
gazePoint
.
hasLink
)
{
if
(
gazePoint
.
hasLink
)
{
gm
.
addGazePoint
(
gazePoint
);
}
}
...
...
resources/js/index.js
View file @
9064e309
...
...
@@ -23,6 +23,7 @@ function initStarGazer() {
StarGazer
.
init
({
canvas
:
document
.
querySelector
(
"canvas"
),
fps
:
60
,
showFPS
:
true
,
width
:
800
,
height
:
800
,
});
...
...
@@ -41,7 +42,7 @@ function onGazeDataAvailable(event) {
}
function
onDisconnected
(
event
)
{
console
.
log
(
event
);
console
.
log
(
event
);
}
init
();
\ No newline at end of file
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