-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTime.js
More file actions
63 lines (50 loc) · 1.45 KB
/
Copy pathTime.js
File metadata and controls
63 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Time{
constructor() {
this._current_time = null; // überprüfen
this._last_time = null;
this._frames_since_start = 0;
this._time_since_start_mil = null;
this._time_since_start_sec = null;
this._time_since_start_min = null;
}
get time_since_start_sec() {
return this._time_since_start_sec;
}
get time_since_start_min() {
return this._time_since_start_min;
}
get time_since_start_mil() {
return this._time_since_start_mil;
}
updateTime()
{
this._time_since_start_mil += this.calculateTime();
this._time_since_start_sec = Math.floor(this._time_since_start_mil / 1000);
this._time_since_start_min = Math.floor(this._time_since_start_mil / 60000);
}
resetTime()
{
this._time_since_start_mil = 0;
this._last_time = null;
}
calculateTime()
{
if(this._last_time != null)
{
this._current_time = Date.now();
let temp_time_last_frame = this._current_time - this._last_time;
this._last_time = this._current_time;
return temp_time_last_frame;
}
else
{
this._current_time = Date.now();
this._last_time = this._current_time;
return 0;
}
}
timeTillNextFrame()
{
return 13;
}
}