@@ -114,7 +114,7 @@ module.exports = class AnimationsController {
114114 this . scheduleTurn ( this . maze . startDirection ) ;
115115 } , danceTime + 150 ) ;
116116 } else {
117- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , tiles . directionToFrame ( this . maze . pegmanD ) ) ;
117+ this . displayPegman ( this . maze . getPegmanX ( ) , this . maze . getPegmanY ( ) , tiles . directionToFrame ( this . maze . getPegmanD ( ) ) ) ;
118118
119119 const finishIcon = document . getElementById ( 'finish' ) ;
120120 if ( finishIcon ) {
@@ -269,10 +269,10 @@ module.exports = class AnimationsController {
269269 * @param {number } endX X coordinate of the target position
270270 * @param {number } endY Y coordinate of the target position
271271 */
272- scheduleMove ( endX , endY , timeForAnimation ) {
273- var startX = this . maze . pegmanX ;
274- var startY = this . maze . pegmanY ;
275- var direction = this . maze . pegmanD ;
272+ scheduleMove ( endX , endY , timeForAnimation , id = null ) {
273+ var startX = this . maze . getPegmanX ( id ) ;
274+ var startY = this . maze . getPegmanY ( id ) ;
275+ var direction = this . maze . getPegmanD ( id ) ;
276276
277277 var deltaX = ( endX - startX ) ;
278278 var deltaY = ( endY - startY ) ;
@@ -338,15 +338,15 @@ module.exports = class AnimationsController {
338338 * Schedule the animations for a turn from the current direction
339339 * @param {number } endDirection The direction we're turning to
340340 */
341- scheduleTurn ( endDirection ) {
341+ scheduleTurn ( endDirection , id = null ) {
342342 var numFrames = 4 ;
343- var startDirection = this . maze . pegmanD ;
343+ var startDirection = this . maze . getPegmanD ( id ) ;
344344 var deltaDirection = endDirection - startDirection ;
345345 utils . range ( 1 , numFrames ) . forEach ( ( frame ) => {
346346 timeoutList . setTimeout ( ( ) => {
347347 this . displayPegman (
348- this . maze . pegmanX ,
349- this . maze . pegmanY ,
348+ this . maze . getPegmanX ( id ) ,
349+ this . maze . getPegmanY ( id ) ,
350350 tiles . directionToFrame ( startDirection + deltaDirection * frame / numFrames ) ) ;
351351 } , this . maze . stepSpeed * ( frame - 1 ) ) ;
352352 } ) ;
@@ -392,8 +392,10 @@ module.exports = class AnimationsController {
392392 }
393393 }
394394
395- scheduleWallHit ( targetX , targetY , deltaX , deltaY , frame ) {
395+ scheduleWallHit ( targetX , targetY , deltaX , deltaY , frame , id = null ) {
396396 // Play the animation of hitting the wall
397+ const pegmanX = this . maze . getPegmanX ( id ) ;
398+ const pegmanY = this . maze . getPegmanY ( id ) ;
397399 if ( this . maze . skin . hittingWallAnimation ) {
398400 var wallAnimationIcon = document . getElementById ( 'wallAnimation' ) ;
399401 var numFrames = this . maze . skin . hittingWallAnimationFrameNumber || 0 ;
@@ -410,8 +412,8 @@ module.exports = class AnimationsController {
410412 // animate our sprite sheet
411413 var timePerFrame = 100 ;
412414 this . scheduleSheetedMovement_ ( {
413- x : this . maze . pegmanX ,
414- y : this . maze . pegmanY
415+ x : pegmanX ,
416+ y : pegmanY
415417 } , {
416418 x : deltaX ,
417419 y : deltaY
@@ -424,10 +426,10 @@ module.exports = class AnimationsController {
424426 // active our gif
425427 timeoutList . setTimeout ( ( ) => {
426428 wallAnimationIcon . setAttribute ( 'x' ,
427- this . maze . SQUARE_SIZE * ( this . maze . pegmanX + 0.5 + deltaX * 0.5 ) -
429+ this . maze . SQUARE_SIZE * ( pegmanX + 0.5 + deltaX * 0.5 ) -
428430 wallAnimationIcon . getAttribute ( 'width' ) / 2 ) ;
429431 wallAnimationIcon . setAttribute ( 'y' ,
430- this . maze . SQUARE_SIZE * ( this . maze . pegmanY + 1 + deltaY * 0.5 ) -
432+ this . maze . SQUARE_SIZE * ( pegmanY + 1 + deltaY * 0.5 ) -
431433 wallAnimationIcon . getAttribute ( 'height' ) ) ;
432434 wallAnimationIcon . setAttribute ( 'visibility' , 'visible' ) ;
433435 wallAnimationIcon . setAttributeNS (
@@ -437,14 +439,14 @@ module.exports = class AnimationsController {
437439 }
438440 }
439441 timeoutList . setTimeout ( ( ) => {
440- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , frame ) ;
442+ this . displayPegman ( pegmanX , pegmanY , frame , id ) ;
441443 } , this . maze . stepSpeed ) ;
442444 timeoutList . setTimeout ( ( ) => {
443- this . displayPegman ( this . maze . pegmanX + deltaX / 4 , this . maze . pegmanY + deltaY / 4 ,
444- frame ) ;
445+ this . displayPegman ( pegmanX + deltaX / 4 , pegmanY + deltaY / 4 ,
446+ frame , id ) ;
445447 } , this . maze . stepSpeed * 2 ) ;
446448 timeoutList . setTimeout ( ( ) => {
447- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , frame ) ;
449+ this . displayPegman ( pegmanX , pegmanY , frame , id ) ;
448450 } , this . maze . stepSpeed * 3 ) ;
449451
450452 if ( this . maze . skin . wallPegmanAnimation ) {
@@ -453,24 +455,24 @@ module.exports = class AnimationsController {
453455 pegmanIcon . setAttribute ( 'visibility' , 'hidden' ) ;
454456 this . updatePegmanAnimation_ ( {
455457 idStr : 'wall' ,
456- row : this . maze . pegmanY ,
457- col : this . maze . pegmanX ,
458- direction : this . maze . pegmanD
458+ row : pegmanY ,
459+ col : pegmanX ,
460+ direction : this . maze . getPegmanD ( id )
459461 } ) ;
460462 } , this . maze . stepSpeed * 4 ) ;
461463 }
462464 }
463465
464- scheduleObstacleHit ( targetX , targetY , deltaX , deltaY , frame ) {
466+ scheduleObstacleHit ( targetX , targetY , deltaX , deltaY , frame , id = null ) {
465467 // Play the animation
466468 var obsId = targetX + this . maze . map . COLS * targetY ;
467469 var obsIcon = document . getElementById ( 'obstacle' + obsId ) ;
468470 obsIcon . setAttributeNS (
469471 'http://www.w3.org/1999/xlink' , 'xlink:href' ,
470472 this . maze . skin . obstacleAnimation ) ;
471473 timeoutList . setTimeout ( ( ) => {
472- this . displayPegman ( this . maze . pegmanX + deltaX / 2 ,
473- this . maze . pegmanY + deltaY / 2 ,
474+ this . displayPegman ( this . maze . getPegmanX ( id ) + deltaX / 2 ,
475+ this . maze . getPegmanY ( id ) + deltaY / 2 ,
474476 frame ) ;
475477 } , this . maze . stepSpeed ) ;
476478
@@ -539,8 +541,10 @@ module.exports = class AnimationsController {
539541 * puzzle (vs. dancing on load).
540542 * @param {integer } timeAlloted How much time we have for our animations
541543 */
542- scheduleDance ( victoryDance , timeAlloted ) {
544+ scheduleDance ( victoryDance , timeAlloted , id = null ) {
543545 const finishIcon = document . getElementById ( 'finish' ) ;
546+ const pegmanX = this . maze . getPegmanX ( id ) ;
547+ const pegmanY = this . maze . getPegmanY ( id ) ;
544548
545549 // Some skins (like scrat) have custom celebration animations we want to
546550 // suport
@@ -550,7 +554,7 @@ module.exports = class AnimationsController {
550554 }
551555 const numFrames = this . maze . skin . celebratePegmanRow ;
552556 const timePerFrame = timeAlloted / numFrames ;
553- const start = { x : this . maze . pegmanX , y : this . maze . pegmanY } ;
557+ const start = { x : pegmanX , y : pegmanY } ;
554558
555559 this . scheduleSheetedMovement_ (
556560 { x : start . x , y : start . y } ,
@@ -564,8 +568,8 @@ module.exports = class AnimationsController {
564568 return ;
565569 }
566570
567- var originalFrame = tiles . directionToFrame ( this . maze . pegmanD ) ;
568- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , 16 ) ;
571+ var originalFrame = tiles . directionToFrame ( this . maze . getPegmanD ( id ) ) ;
572+ this . displayPegman ( pegmanX , pegmanY , 16 , id ) ;
569573
570574 // If victoryDance === true, play the goal animation, else reset it
571575 if ( victoryDance && finishIcon ) {
@@ -575,21 +579,21 @@ module.exports = class AnimationsController {
575579
576580 var danceSpeed = timeAlloted / 5 ;
577581 timeoutList . setTimeout ( ( ) => {
578- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , 18 ) ;
582+ this . displayPegman ( pegmanX , pegmanY , 18 , id ) ;
579583 } , danceSpeed ) ;
580584 timeoutList . setTimeout ( ( ) => {
581- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , 20 ) ;
585+ this . displayPegman ( pegmanX , pegmanY , 20 , id ) ;
582586 } , danceSpeed * 2 ) ;
583587 timeoutList . setTimeout ( ( ) => {
584- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , 18 ) ;
588+ this . displayPegman ( pegmanX , pegmanY , 18 , id ) ;
585589 } , danceSpeed * 3 ) ;
586590 timeoutList . setTimeout ( ( ) => {
587- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , 20 ) ;
591+ this . displayPegman ( pegmanX , pegmanY , 20 , id ) ;
588592 } , danceSpeed * 4 ) ;
589593
590594 timeoutList . setTimeout ( ( ) => {
591595 if ( ! victoryDance || this . maze . skin . turnAfterVictory ) {
592- this . displayPegman ( this . maze . pegmanX , this . maze . pegmanY , originalFrame ) ;
596+ this . displayPegman ( pegmanX , pegmanY , originalFrame , id ) ;
593597 }
594598
595599 if ( victoryDance && this . maze . skin . transparentTileEnding ) {
@@ -642,7 +646,7 @@ module.exports = class AnimationsController {
642646 * @param {number } y Vertical grid (or fraction thereof).
643647 * @param {number } frame Direction (0 - 15) or dance (16 - 17).
644648 */
645- displayPegman ( x , y , frame ) {
649+ displayPegman ( x , y , frame , id = null ) {
646650 var pegmanIcon = document . getElementById ( 'pegman' ) ;
647651 var clipRect = document . getElementById ( 'clipRect' ) ;
648652 displayPegman ( this . maze . skin , pegmanIcon , clipRect , x , y , frame ) ;
0 commit comments