@@ -51,7 +51,7 @@ var SeparateX = function (collisionInfo)
5151 // console.log('%c X frame ' + body1.world._frame + ' ', 'background-color: orange');
5252 // console.log('body1:', body1.gameObject.name, 'vs body2:', body2.gameObject.name);
5353 // console.log('pre-GetOverlap bx = body1', body1.x, 'body2', body2.x);
54- console . log ( 'x compare (PRE-SX):' , body1 . right , 'body2' , body2 . x , '=' , ( body1 . right - body2 . x ) ) ;
54+ // console.log('x compare (PRE-SX):', body1.right, 'body2', body2.x, '=', (body1.right - body2.x));
5555
5656 // console.log('pre-GetOverlap by = body1', body1.y, 'body2', body2.y);
5757 // console.log('pre-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
@@ -65,7 +65,7 @@ var SeparateX = function (collisionInfo)
6565 // Can't separate two immovable bodies, or a body with its own custom separation logic
6666 if ( ! intersects || overlapOnly || ( body1Immovable && body2Immovable ) || body1 . customSeparateX || body2 . customSeparateX )
6767 {
68- console . log ( this . world . _frame , 'SeparateX aborted' ) ;
68+ // console.log(this.world._frame, 'SeparateX aborted');
6969
7070 // return true if there was some overlap, otherwise false.
7171 return ( ( intersects && overlap !== 0 ) || ( body1 . embedded && body2 . embedded ) ) ;
@@ -81,10 +81,10 @@ var SeparateX = function (collisionInfo)
8181 // At this point, the velocity from gravity, world rebounds, etc has been factored in.
8282 // The body is moving the direction it wants to, but may be blocked and rebound.
8383
84- var moving1 = body1 . movingX ( ) ;
85- var moving2 = body2 . movingX ( ) ;
84+ var canMove1 = body1 . canMoveX ( ) ;
85+ var canMove2 = body2 . canMoveX ( ) ;
8686
87- if ( moving1 && moving2 )
87+ if ( canMove1 && canMove2 )
8888 {
8989 // Neither body is immovable, so they get a new velocity based on mass
9090 var mass1 = body1 . mass ;
@@ -124,7 +124,7 @@ var SeparateX = function (collisionInfo)
124124 // console.log('sqrt mult', bnx1, bnx2);
125125 // console.log('delta', body1.deltaY(), body2.deltaY());
126126 }
127- else if ( ! moving1 && moving2 )
127+ else if ( ! canMove1 && canMove2 )
128128 {
129129 // Body1 is immovable, so adjust body2 speed
130130
@@ -145,7 +145,7 @@ var SeparateX = function (collisionInfo)
145145 // console.log('wb = body1', body1.worldBlocked.down, 'body2', body2.worldBlocked.down);
146146 // console.log('sleeping? = body1', body1.sleeping, 'body2', body2.sleeping);
147147 }
148- else if ( moving1 && ! moving2 )
148+ else if ( canMove1 && ! canMove2 )
149149 {
150150 // Body2 is immovable, so adjust body1 speed
151151
@@ -220,40 +220,40 @@ var SeparateX = function (collisionInfo)
220220 // The left of Body1 overlaps with the right of Body2
221221 if ( body2 . isBlockedLeft ( ) )
222222 {
223- console . log ( 'nx1 <> 0 left block left' , body1 . x ) ;
223+ // console.log('nx1 <> 0 left block left', body1.x);
224224 body1 . setBlockedLeft ( collisionInfo , body2 ) ;
225225 }
226226 else
227227 {
228- console . log ( 'nx1 <> 0 left add' , body1 . x ) ;
229- body1 . x += body1 . getMoveX ( totalA ) ;
228+ // console.log('nx1 <> 0 left add', body1.x);
229+ body1 . moveX ( totalA ) ;
230230 }
231231 }
232232 else if ( rightFace )
233233 {
234234 // The right of Body1 overlaps with the left of Body2
235235 if ( body2 . isBlockedRight ( ) )
236236 {
237- console . log ( 'nx1 <> 0 right block right' , body1 . x ) ;
237+ // console.log('nx1 <> 0 right block right', body1.x);
238238 body1 . setBlockedRight ( collisionInfo , body2 ) ;
239239 }
240240 else
241241 {
242- console . log ( 'nx1 <> 0 right add' , body1 . x ) ;
243- body1 . x += body1 . getMoveX ( totalA ) ;
242+ // console.log('nx1 <> 0 right add', body1.x);
243+ body1 . moveX ( totalA ) ;
244244 }
245245 }
246246
247247 // If Body1 cannot move up, it doesn't matter what new velocity it has.
248248 if ( body1 . sleeping && ( nx1 < 0 && body1 . isBlockedLeft ( ) ) || ( nx1 > 0 && body1 . isBlockedRight ( ) ) )
249249 {
250- console . log ( 'nx1 <> 0 zero sleep' ) ;
250+ // console.log('nx1 <> 0 zero sleep');
251251 nx1 = 0 ;
252252 }
253253 }
254254 else if ( body1 . moves )
255255 {
256- console . log ( 'body1 stationary' , body1 . right ) ;
256+ // console.log('body1 stationary', body1.right);
257257
258258 // Body1 is now stationary
259259
@@ -267,7 +267,7 @@ var SeparateX = function (collisionInfo)
267267 // if (totalA !== 0 && !body1.isBlockedRight())
268268 // {
269269 // console.log('body1 stationary leftface add', body1.x, 'totalA', totalA);
270- body1 . x += body1 . getMoveX ( totalA ) ;
270+ body1 . moveX ( totalA ) ;
271271 // }
272272
273273 if ( body2 . isBlockedLeft ( ) )
@@ -287,7 +287,7 @@ var SeparateX = function (collisionInfo)
287287 // if (totalA !== 0 && !body1.isBlockedLeft())
288288 // {
289289 // console.log('body1 stationary rightface add', body1.x);
290- body1 . x += body1 . getMoveX ( totalA ) ;
290+ body1 . moveX ( totalA ) ;
291291 // }
292292
293293 if ( body2 . isBlockedRight ( ) )
@@ -308,40 +308,40 @@ var SeparateX = function (collisionInfo)
308308 // The bottom of Body2 overlaps with the top of Body1
309309 if ( body1 . isBlockedRight ( ) )
310310 {
311- console . log ( 'nx2 <> 0 leftface down' , body2 . x ) ;
311+ // console.log('nx2 <> 0 leftface down', body2.x);
312312 body2 . setBlockedRight ( collisionInfo , body1 ) ;
313313 }
314314 else
315315 {
316- console . log ( 'nx2 <> 0 leftface add' , body2 . x ) ;
317- body2 . x += body2 . getMoveX ( totalB ) ;
316+ // console.log('nx2 <> 0 leftface add', body2.x);
317+ body2 . moveX ( totalB ) ;
318318 }
319319 }
320320 else if ( rightFace )
321321 {
322322 // The top of Body2 overlaps with the bottom of Body1
323323 if ( body1 . isBlockedLeft ( ) )
324324 {
325- console . log ( 'nx2 <> 0 rightface down' , body2 . x ) ;
325+ // console.log('nx2 <> 0 rightface down', body2.x);
326326 body2 . setBlockedLeft ( collisionInfo , body1 ) ;
327327 }
328328 else
329329 {
330- console . log ( 'nx2 <> 0 rightface add' , body2 . x ) ;
331- body2 . x += body2 . getMoveX ( totalB ) ;
330+ // console.log('nx2 <> 0 rightface add', body2.x);
331+ body2 . moveX ( totalB ) ;
332332 }
333333 }
334334
335335 // If Body2 cannot move up or down, it doesn't matter what new velocity it has
336336 if ( body2 . sleeping && ( nx2 < 0 && body2 . isBlockedLeft ( ) ) || ( nx2 > 0 && body2 . isBlockedRight ( ) ) )
337337 {
338- console . log ( 'nx2 <> 0 zero sleep' ) ;
338+ // console.log('nx2 <> 0 zero sleep');
339339 nx2 = 0 ;
340340 }
341341 }
342342 else if ( body2 . moves )
343343 {
344- console . log ( 'body2 stationary' , body2 . x ) ;
344+ // console.log('body2 stationary', body2.x);
345345
346346 // Body2 is stationary
347347 if ( leftFace )
@@ -354,7 +354,7 @@ var SeparateX = function (collisionInfo)
354354 // if (totalB !== 0 && !body2.isBlockedRight())
355355 // {
356356 // console.log('body2 stationary leftface add', body2.x);
357- body2 . x += body2 . getMoveX ( totalB ) ;
357+ body2 . moveX ( totalB ) ;
358358 // }
359359
360360 if ( body1 . isBlockedRight ( ) )
@@ -373,7 +373,7 @@ var SeparateX = function (collisionInfo)
373373 // if (totalB !== 0 && !body2.isBlockedLeft())
374374 // {
375375 // console.log('body2 stationary rightface add', body2.x);
376- body2 . x += body2 . getMoveX ( totalB ) ;
376+ body2 . moveX ( totalB ) ;
377377 // }
378378
379379 if ( body1 . isBlockedLeft ( ) )
@@ -434,7 +434,7 @@ var SeparateX = function (collisionInfo)
434434 // console.log('post-GetOverlap bx = body1', body1.x, 'body2', body2.x);
435435 // console.log('post-GetOverlap bs = body1', body1.right, 'body2', body2.right);
436436
437- console . log ( 'x compare (POST-SX):' , body1 . right , 'body2' , body2 . x , '=' , ( body1 . right - body2 . x ) ) ;
437+ // console.log('x compare (POST-SX):', body1.right, 'body2', body2.x, '=', (body1.right - body2.x));
438438
439439 // If we got this far then there WAS overlap, and separation is complete, so return true
440440 return true ;
0 commit comments