Skip to content

Commit

Permalink
Gravity slider
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii Lytvyn authored and Serhii Lytvyn committed Feb 6, 2022
1 parent 5dad5e5 commit 7671b86
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ function setup() {
slider.position(10, 50);
slider.style('width', '80px');

sliderCapacity = createSlider(1, 200, 8, 1);
sliderCapacity = createSlider(1, 20, 2, 1);
sliderCapacity.position(10, 80);
sliderCapacity.style('width', '80px');

sliderGravity = createSlider(1, 200, 2, 1);
sliderGravity.position(10, 110);
sliderGravity.style('width', '80px');

boundary = new Boundary(0, 0, window_size_x, window_size_y);

for (let i = 0; i < 8000; i++) {
Expand All @@ -208,6 +212,7 @@ function setup() {
function draw() {
background(40);

gravity = createVector(0, sliderGravity.value() / 10000)
let qt = new QuadTree(boundary, sliderCapacity.value());

qt.showBoundary();
Expand All @@ -224,6 +229,7 @@ function draw() {
text("framerate: " + Math.floor(frameRate()), 10, 20);
text("particles count: " + slider.value(), 10, 40);
text("tree capacity: " + sliderCapacity.value(), 10, 80);
text("gravity: " + sliderGravity.value() / 10000, 10, 110);
}

function showAndMovePoints(qt) {
Expand Down

0 comments on commit 7671b86

Please sign in to comment.