Skip to content

Commit b102903

Browse files
Built in stopwatch
1 parent 1f1c492 commit b102903

File tree

5 files changed

+19
-43
lines changed

5 files changed

+19
-43
lines changed

JS/MainLoop.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ function mainLoop(particlesLeft, particlesRight, translation) {
5353
c.fill()
5454
c.closePath()
5555
}
56+
57+
if(isStopwatchRunning){
58+
stopwatchTime += 1;
59+
$('#time').html(Math.round(stopwatchTime/fps));
60+
}
5661
}
5762

5863
function average(array) {

JS/Start.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var particleMass = 5;
3333
var ctx;
3434
var gameLoop;
3535
var mouse;
36+
var stopwatchTime;
37+
var isStopwatchRunning;
3638

3739
$(function(){
3840
var canvas = document.getElementById('mainCanvas');
@@ -151,8 +153,13 @@ function printInputs() {
151153

152154
}
153155

154-
function openStopwatch(){
155-
window.open('stopwatch.html', '_blank', 'channelmode=yes');
156+
function startStopwatch(){
157+
stopwatchTime = 0;
158+
isStopwatchRunning = true;
159+
}
160+
function stopStopwatch(){
161+
stopwatchTime = 0;
162+
isStopwatchRunning = false;
156163
}
157164

158165
function refreshSize() {

0 commit comments

Comments
 (0)