Learn Intermediate OOP by Building a Platformer Game - Step 81

Tell us what’s happening:

if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) {
  platforms.forEach((platform) => {
    platform.position.x -= 5;
  });
} else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) {
  platforms.forEach((platform) => {
    platform.position.x += 5;
  });

Can someone please explain me this shouldn’t it be the oposite over here shouldn/t we on moving right add +5 as value and on moving left -5

Your code so far

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

/* file: styles.css */

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



// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 81

Hi! That part defines platforms movement. To give the feeling that the player is moving around the map, platforms should go the opposite direction, that is, when player moves to the right platforms move to the left.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.