File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ class GeneratedDancer {
4040
4141 this . graphics = this . p5 . createGraphics ( worldW , worldH ) ;
4242 this . graphics . pixelDensity ( 1 ) ;
43+ this . danceMove = null ;
4344
4445 // Hand the renderer our mid-layer 2D context.
4546 this . renderer . init ( this . graphics . drawingContext ) ;
@@ -49,6 +50,7 @@ class GeneratedDancer {
4950 if ( typeof src === 'number' ) {
5051 src = movesById [ src ] || movesById [ 0 ] ;
5152 }
53+ this . danceMove = src ;
5254 return this . renderer . setSource ( src ) ;
5355 }
5456
@@ -94,6 +96,24 @@ class GeneratedDancer {
9496 this . renderer = null ;
9597 this . p5 = null ;
9698 }
99+
100+ shouldMirror ( currentMeasure ) {
101+ const movesToMirror = new Set ( [
102+ 'rest' ,
103+ 'clap_high' ,
104+ 'dab' ,
105+ 'drop' ,
106+ 'floss' ,
107+ 'fresh' ,
108+ 'kick' ,
109+ 'roll' ,
110+ 'thriller' ,
111+ ] ) ;
112+ return (
113+ movesToMirror . has ( this . danceMove ) &&
114+ Math . floor ( currentMeasure * 2 ) % 2 === 1
115+ ) ;
116+ }
97117}
98118
99119module . exports = GeneratedDancer ;
Original file line number Diff line number Diff line change @@ -683,7 +683,6 @@ module.exports = class DanceParty {
683683 animationLength - 1 ,
684684 Math . floor ( measureTick * animationLength )
685685 ) ;
686-
687686 this . generatedDancer . render ( measureFrame ) ;
688687 }
689688 } ;
@@ -695,6 +694,9 @@ module.exports = class DanceParty {
695694
696695 sprite . draw = ( ) => {
697696 if ( this . generatedDancer ) {
697+ sprite . mirrorX (
698+ this . generatedDancer . shouldMirror ( this . getCurrentMeasure ( ) ) ? - 1 : 1
699+ ) ;
698700 this . p5_ . image (
699701 this . generatedDancer . graphics ,
700702 sprite . x - location . x ,
@@ -1654,7 +1656,7 @@ module.exports = class DanceParty {
16541656 if ( ! this . generatedDancer ) {
16551657 return ;
16561658 }
1657-
1659+ this . danceMove = source ;
16581660 this . generatedDancer . setSource ( source ) ;
16591661 }
16601662
You can’t perform that action at this time.
0 commit comments