src/games/RunBabyRun/RunBabyRun.js
// Returns the platform the stick hit (if it didn't hit any stick then return undefined)
Returns the platform the stick hit (if it didn't hit any stick then return undefined)
Returns the platform the stick hit ( if it didn ' t hit any stick then return undefined )
function thePlatformTheStickHits() {
    if (sticks.last().rotation !== 90)
      throw Error(`Stick is ${sticks.last().rotation}°`);
    const stickFarX = sticks.last().x + sticks.last().length;
    const platformTheStickHits = platforms.find(
      (platform) => platform.x < stickFarX && stickFarX < platform.x + platform.w
    );
    if (
      platformTheStickHits &&
      platformTheStickHits.x + platformTheStickHits.w / 2 - perfectAreaSize / 2 <
        stickFarX &&
      stickFarX <
        platformTheStickHits.x + platformTheStickHits.w / 2 + perfectAreaSize / 2
    )
      return [platformTheStickHits, true];
    return [platformTheStickHits, false];
  }
function thePlatformTheStickHits ( ) { if ( sticks . last ( ) . rotation !== 90 ) throw Error ( ` ${ sticks . last ( ) . rotation } ) ; const stickFarX = sticks . last ( ) . x + sticks . last ( ) . length ; const platformTheStickHits = platforms . find ( ( platform ) => platform . x < stickFarX && stickFarX < platform . x + platform . w ) ; if ( platformTheStickHits && platformTheStickHits . x + platformTheStickHits . w / 2 - perfectAreaSize / 2 < stickFarX && stickFarX < platformTheStickHits . x + platformTheStickHits . w / 2 + perfectAreaSize / 2 ) return [ platformTheStickHits , true ] ; return [ platformTheStickHits , false ] ; }
Returns the platform the stick hit (if it didn't hit any stick then return undefined)
Returns the platform the stick hit ( if it didn ' t hit any stick then return undefined )
// If the stick hits the perfect area