@@ -60,7 +60,7 @@ function reset() {
60
60
}
61
61
}
62
62
63
- let Liquid = function ( x , y , w , h , c ) {
63
+ let Liquid = function ( x , y , w , h , c ) {
64
64
this . x = x ;
65
65
this . y = y ;
66
66
this . w = w ;
@@ -69,7 +69,7 @@ let Liquid = function (x, y, w, h, c) {
69
69
} ;
70
70
71
71
// Is the Mover in the Liquid?
72
- Liquid . prototype . contains = function ( m ) {
72
+ Liquid . prototype . contains = function ( m ) {
73
73
let l = m . position ;
74
74
return (
75
75
l . x > this . x &&
@@ -80,7 +80,7 @@ Liquid.prototype.contains = function (m) {
80
80
} ;
81
81
82
82
// Calculate drag force
83
- Liquid . prototype . calculateDrag = function ( m ) {
83
+ Liquid . prototype . calculateDrag = function ( m ) {
84
84
// Magnitude is coefficient * speed squared
85
85
let speed = m . velocity . mag ( ) ;
86
86
let dragMagnitude = this . c * speed * speed ;
@@ -96,7 +96,7 @@ Liquid.prototype.calculateDrag = function (m) {
96
96
return dragForce ;
97
97
} ;
98
98
99
- Liquid . prototype . display = function ( ) {
99
+ Liquid . prototype . display = function ( ) {
100
100
noStroke ( ) ;
101
101
fill ( 50 ) ;
102
102
rect ( this . x , this . y , this . w , this . h ) ;
@@ -111,12 +111,12 @@ function Mover(m, x, y) {
111
111
112
112
// Newton's 2nd law: F = M * A
113
113
// or A = F / M
114
- Mover . prototype . applyForce = function ( force ) {
114
+ Mover . prototype . applyForce = function ( force ) {
115
115
let f = p5 . Vector . div ( force , this . mass ) ;
116
116
this . acceleration . add ( f ) ;
117
117
} ;
118
118
119
- Mover . prototype . update = function ( ) {
119
+ Mover . prototype . update = function ( ) {
120
120
// Velocity changes according to acceleration
121
121
this . velocity . add ( this . acceleration ) ;
122
122
// position changes by velocity
@@ -125,15 +125,15 @@ Mover.prototype.update = function () {
125
125
this . acceleration . mult ( 0 ) ;
126
126
} ;
127
127
128
- Mover . prototype . display = function ( ) {
128
+ Mover . prototype . display = function ( ) {
129
129
stroke ( 0 ) ;
130
130
strokeWeight ( 2 ) ;
131
131
fill ( 255 , 127 ) ;
132
132
ellipse ( this . position . x , this . position . y , this . mass * 16 , this . mass * 16 ) ;
133
133
} ;
134
134
135
135
// Bounce off bottom of window
136
- Mover . prototype . checkEdges = function ( ) {
136
+ Mover . prototype . checkEdges = function ( ) {
137
137
if ( this . position . y > height - this . mass * 8 ) {
138
138
// A little dampening when hitting the bottom
139
139
this . velocity . y *= - 0.9 ;
0 commit comments