Skip to content

Commit ca04403

Browse files
adder/subtractor
1 parent 5ab83a6 commit ca04403

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

JS/MainLoop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function average(array) {
7979
function particleCollisions(checkIndex, particles) {
8080
particle = particles[checkIndex];
8181
particles.map(function (particleToCheck, i) {
82-
if (i != checkIndex && i != 0 && i < checkIndex) {
82+
if (i < checkIndex) {
8383
var distance = particleToCheck.distance(particle);
8484
if (distance.r <= particleToCheck.radius + particle.radius) {
8585
let wallAngle = distance.deg + 90;

JS/Start.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,33 @@ function printInputs() {
152152
} else {
153153
settingInput.val(initValue);
154154
}
155-
155+
if(settingInput.attr('type')=='range'){
156+
settingContainer.append($('<button class="adder">+</buttom>'));
157+
settingContainer.append($('<button class="subtractor">-</buttom>'));
158+
}
156159
});
157160
$('[type="range"]').change(function(e){
158161
let target = $(this);
159162
target.parent().children('p').html(target.val())
160163
});
164+
$('.adder').click(function(e){
165+
let target = $(this);
166+
let varName = target.parent().attr('var');
167+
let value = window[varName];
168+
value++;
169+
window[varName] = value;
170+
target.parent().children('input').val(value);
171+
target.parent().children('p').html(value);
172+
});
173+
$('.subtractor').click(function(e){
174+
let target = $(this);
175+
let varName = target.parent().attr('var');
176+
let value = window[varName];
177+
value--;
178+
window[varName] = value;
179+
target.parent().children('input').val(value);
180+
target.parent().children('p').html(value);
181+
});
161182
//Clock is http://flipclockjs.com/
162183

163184
}

0 commit comments

Comments
 (0)