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