Learn Intermediate OOP by Building a Platformer Game - Step 84

Tell us what’s happening:

player.position.y + player.height <= platform.position.y, // will check if the position of the player + his height is less than platforms height
player.position.y + player.height + player.velocity.y >= platform.position.y,
player.position.x >= platform.position.x - player.width/2

can someone explain the other two cases and also why we have taken the width/2 in the third case

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region


  platforms.forEach((platform) => {
    const collisionDetectionRules = [
      player.position.y + player.height <= platform.position.y,
      player.position.y + player.height + player.velocity.y >= platform.position.y,
      player.position.x >= platform.position.x - player.width
    ];
  });


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 84

player.width / 2 , This is often used to ensure that the player’s sprite doesn’t visually pass through the platform’s edge when they are in close proximity horizontally.