Skip to content

Commit 7aec35d

Browse files
Beautify + Stopwatch
1 parent 9a39b3b commit 7aec35d

File tree

10 files changed

+571
-274
lines changed

10 files changed

+571
-274
lines changed

CSS/flipclock.css

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

CSS/main.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#canvasContainer {
2+
margin: auto;
3+
font-size: 2em;
4+
}
5+
6+
#settings {
7+
display: block;
8+
width: 70%;
9+
margin: auto;
10+
}
11+
12+
.center {
13+
text-align: center;
14+
width: 100%;
15+
}
16+
17+
.block {
18+
display: block;
19+
}
20+
21+
.floatLeft {
22+
float: left;
23+
}
24+
25+
.collumns2 {
26+
column-count: 2;
27+
-moz-column-count: 2;
28+
}
29+
30+
.collumns3 {
31+
column-count: 3;
32+
-moz-column-count: 3;
33+
}
34+
35+
.floatRight {
36+
float: right;
37+
}
38+
39+
p {
40+
display: inline;
41+
}
42+
43+
.wide {
44+
width: 100%%;
45+
}

JS/Click.js

Lines changed: 0 additions & 107 deletions
This file was deleted.

JS/LightenColor.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

JS/Line.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

JS/MainLoop.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ function mainLoop(particlesLeft, particlesRight, translation) {
2424

2525
c.strokeStyle = 'black';
2626
c.lineWidth = 0.2;
27-
if (particle.clickHandler.isActive) {
28-
var forceLine = new Line(particle, mouse);
29-
forceLine.stroke(c);
30-
}
3127
});
3228

3329
$('#tempLeft').html(Math.round(average(leftTemps)* particleMass));
@@ -43,18 +39,14 @@ function mainLoop(particlesLeft, particlesRight, translation) {
4339

4440
c.strokeStyle = 'black';
4541
c.lineWidth = 0.2;
46-
if (particle.clickHandler.isActive) {
47-
var forceLine = new Line(particle, mouse);
48-
forceLine.stroke(c);
49-
}
5042
});
5143

5244
$('#tempRight').html(Math.round(average(rightTemps) * particleMass));
5345

5446
if(!allowCrossOver){
5547
c.beginPath()
5648
c.fillStyle = barrierColor;
57-
c.rect(c.canvas.width/2.1, 0, (0.1*c.canvas.width)/2.1, c.canvas.height)
49+
c.rect(c.canvas.width/canvasRatio, 0, ((2-canvasRatio)*c.canvas.width)/canvasRatio, c.canvas.height)
5850
c.fill()
5951
c.closePath()
6052
}

JS/Poly.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

JS/Start.js

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ var backgroundColor = '#BFBFBF';
2020
var particleColor = '#453FC0';
2121
var barrierColor = '#ff0000';
2222
var particleRadius = 0.5;
23-
var canvasRatio = 2.1;
23+
var canvasRatio = 2.01;
2424
var isFriction = false;
25-
var allowCrossOver = false
25+
var allowCrossOver = false;
2626
var particleMass = 5;
2727

2828
//global vars
@@ -40,7 +40,8 @@ $(function(){
4040
});
4141

4242
function resetLoop(){
43-
clearInterval(gameLoop)
43+
allowCrossOver = false;
44+
clearInterval(gameLoop);
4445
init(ctx);
4546
}
4647

@@ -65,7 +66,7 @@ function init(c) {
6566
initForce.r = initTempRight;
6667
initForce.deg = i * (360 / numberOfParticlesRight);
6768
let initPoint = getPointOnCircle(((2 * numberOfParticlesRight - 1) * particleRadius - 1) / (2 * Math.PI), i * (1 / numberOfParticlesRight))
68-
initPoint.x += 160;
69+
initPoint.x += 151;
6970
initPoint.y += 50;
7071

7172
makeParticle(initPoint, particleRadius, particleMass, initForce, particlesRight);
@@ -74,7 +75,7 @@ function init(c) {
7475
//initArrowKeys();
7576

7677
//start loop
77-
gameLoop = setInterval(makeMainLoop(particlesLeft, particlesRight, 110), 1000 / fps);
78+
gameLoop = setInterval(makeMainLoop(particlesLeft, particlesRight, 100), 1000 / fps);
7879
}
7980
window.onresize = refreshSize;
8081

@@ -89,15 +90,6 @@ function makeParticle(initPoint, radius, mass, initForce, list) {
8990
particle.vel.y += accelleration.y;
9091
}
9192
particle.applyForce(initForce);
92-
particle.clickHandler = new Clickable(particle, radius);
93-
particle.clickHandler.onClick = function (startPoint) {
94-
particle.clickHandler.onRelease = function (endPoint) {
95-
var force = new Point(0, 0);
96-
force.x = particle.x - endPoint.x;
97-
force.y = particle.y - endPoint.y;
98-
particle.applyForce(force);
99-
}
100-
}
10193
list.push(particle);
10294
}
10395

@@ -132,12 +124,14 @@ function printInputs() {
132124
}
133125
window[varName] = value;
134126
});
135-
136-
137-
settingContainer.append(varName + ': ');
127+
128+
let alias = settingContainer.attr('alias');
129+
settingContainer.append(alias + ': ');
138130
settingContainer.append(settingInput);
139-
settingContainer.append('<p></p>');
140131
var initValue = window[varName];
132+
if (settingInput.attr('type') == 'range') {
133+
settingContainer.append('<p>'+initValue+'</p>');
134+
}
141135
if (settingInput.attr('type') == 'checkbox') {
142136
settingInput.attr('checked', initValue);
143137
} else {
@@ -149,21 +143,21 @@ function printInputs() {
149143
let target = $(this);
150144
target.parent().children('p').html(target.val())
151145
});
146+
//Clock is http://flipclockjs.com/
147+
let clock = $('.your-clock').FlipClock({});
148+
clock.stop()
149+
$('#startClock').click(function(){clock.start()});
150+
$('#stopClock').click(function(){clock.stop()});
151+
$('#resetClock').click(function(){clock.reset()});
152152
}
153153

154154
function refreshSize() {
155-
if (window.innerWidth < window.innerHeight) {
156-
ctx.canvas.width = window.innerWidth;
157-
ctx.canvas.height = window.innerWidth / canvasRatio;
158-
$('#settings').css('margin-top', ctx.canvas.height);
159-
$('#settings').css('margin-left', 0);
160-
} else {
161-
ctx.canvas.width = window.innerHeight;
162-
ctx.canvas.height = window.innerHeight / canvasRatio;
163-
$('#settings').css('margin-left', ctx.canvas.width);
164-
$('#settings').css('margin-top', 0);
165-
}
166-
155+
ctx.canvas.width = window.innerWidth*0.7;
156+
ctx.canvas.height = window.innerWidth*0.7 / canvasRatio;
157+
$('#canvasContainer').css('width', ctx.canvas.width);
158+
$('#canvasContainer label').css('width', ctx.canvas.width/2.1);
159+
$('#canvasContainer label').css('display', 'inline-block');
160+
$('#canvasContainer label').css('text-align', 'center');
167161
}
168162

169163
function getPointOnCircle(radius, time) {

JS/flipclock.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)