Skip to content

Commit 306b5ac

Browse files
authored
Merge pull request #1360 from Acha0203/fix/examples-en-09-simulate-00-forces
Fix an incorrect text and modify the format of source code on examples/en/09_Simulate/00_Forces
2 parents 6351349 + 5458d4a commit 306b5ac

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/data/examples/en/09_Simulate/00_Forces.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Bodies experience gravity continuously
1010
// Bodies experience fluid resistance when in "water"
1111

12-
// Five moving bodies
12+
// Nine moving bodies
1313
let movers = [];
1414

1515
// Liquid
@@ -29,7 +29,6 @@ function draw() {
2929
liquid.display();
3030

3131
for (let i = 0; i < movers.length; i++) {
32-
3332
// Is the Mover in the liquid?
3433
if (liquid.contains(movers[i])) {
3534
// Calculate drag force
@@ -48,10 +47,8 @@ function draw() {
4847
movers[i].display();
4948
movers[i].checkEdges();
5049
}
51-
5250
}
5351

54-
5552
function mousePressed() {
5653
reset();
5754
}
@@ -74,8 +71,12 @@ let Liquid = function(x, y, w, h, c) {
7471
// Is the Mover in the Liquid?
7572
Liquid.prototype.contains = function(m) {
7673
let l = m.position;
77-
return l.x > this.x && l.x < this.x + this.w &&
78-
l.y > this.y && l.y < this.y + this.h;
74+
return (
75+
l.x > this.x &&
76+
l.x < this.x + this.w &&
77+
l.y > this.y &&
78+
l.y < this.y + this.h
79+
);
7980
};
8081

8182
// Calculate drag force
@@ -127,23 +128,15 @@ Mover.prototype.update = function() {
127128
Mover.prototype.display = function() {
128129
stroke(0);
129130
strokeWeight(2);
130-
fill(255,127);
131+
fill(255, 127);
131132
ellipse(this.position.x, this.position.y, this.mass * 16, this.mass * 16);
132133
};
133134

134135
// Bounce off bottom of window
135136
Mover.prototype.checkEdges = function() {
136-
if (this.position.y > (height - this.mass * 8)) {
137+
if (this.position.y > height - this.mass * 8) {
137138
// A little dampening when hitting the bottom
138139
this.velocity.y *= -0.9;
139-
this.position.y = (height - this.mass * 8);
140+
this.position.y = height - this.mass * 8;
140141
}
141142
};
142-
143-
144-
145-
146-
147-
148-
149-

0 commit comments

Comments
 (0)