Learn Intermediate OOP by Building a Platformer Game - Step 117

Tell us what’s happening:

if (index === checkpoints.length - 1) {
isCheckpointCollisionDetectionActive = false;
showCheckpointScreen(“You reached the final checkpoint!”);
movePlayer(“ArrowRight”, 0, false);
} else if (player.x >= checkpoint.x && player.x <= checkpoint.x + 40) {
// Llama a showCheckpointScreen si el jugador ha llegado a un punto de control intermedio

showCheckpointScreen(“You reached a checkpoint!”);
}
}
nesecito ayuda e probado de mil maneras

Your code so far

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

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


      if (index === checkpoints.length - 1) {
        isCheckpointCollisionDetectionActive = false;
        showCheckpointScreen("You reached the final checkpoint!");
        movePlayer("ArrowRight", 0, false);
      } else if (player.x >= checkpoint.x && player.x <= checkpoint.x + 40) {
  // Llama a showCheckpointScreen si el jugador ha llegado a un punto de control intermedio
  
 
showCheckpointScreen("You reached a checkpoint!");
}
    }

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn Intermediate OOP by Building a Platformer Game - Step 117

You forgot your position properties. See what you did earlier?

const checkpointDetectionRules = [
      player.position.x >= checkpoint.position.x,
      player.position.y >= checkpoint.position.y
    //and so on...

You need to add the position properties to your conditional in the same way: (where’s the position properties?)

(player.x >= checkpoint.x && player.x <= checkpoint.x + 40)

Also, remove the comments. I’m not sure, but for some reason I think they were interfering with the tests.

Let me know if that works.

1 Like

sigue sin responder el const ya esta mas arriba el problema que tengo es con el else if

Perhaps I didn’t explain myself well. You don’t need to modify the const higher up. I just wanted to use it to show you that you need to use .position.x, not just .x on the player and checkpoint objects.

Does that clarify a bit?

If you made any changes to your code since last sharing it, please share the updated code.

else if (player.x >= checkpoint.x && player.x <= checkpoint.x + 40)

showCheckpointScreen("You reached a checkpoint!"); 

eso fue lo que modifique del else if pero sigue sin funcionar

1 Like

You’re so close! The problem lies in your if else conditional statement.

(player.x >= checkpoint.x && player.x <= checkpoint.x + 40)

player.x is not valid. player.position.x is. The same applies for the checkpoint.x parts. You need to fix those. The logic is fine, just the syntax needs fixing.

Does this make sense? Please, feel free to ask questions.

else if (player.position.x >= checkpoint.x && player.position.x <= checkpoint.x + 40) {

showCheckpointScreen("You reached a checkpoint!");
  }

lo cambie pero no sigue igual .

Great work. Yes, you did change it, but you need to change it for the checkpoint conditions too!

Buen trabajo. Sí, lo cambiaste, pero también debes cambiar las condiciones del punto de control.

else if (player.position.x >= checkpoint.x && player.position.x <= checkpoint.x + 40) {
showCheckpointScreen(“You reached a checkpoint!”);

}
como hago eso ?

Just like you did on the player.position.x.

checkpoint.x is invalid. checkpoint.position.x is valid. Same logic. You’re really close!

else if (player.position.x >= v && player.position.x <= checkpoint.position.x + 40) {
showCheckpointScreen(“You reached a checkpoint!”);

}
aca esta cambiado, pero no pasa nada

I don’t see the first checkpoint.position.x. There’s only a “v” there for some reason.

No veo el primer checkpoint.position.x. Por alguna razón, solo hay una “v” allí.

1 Like

mil gracias yo me equivoque y puse v , en vez de checkpoint.position.x. muchas gracias

1 Like

Of course. Happy coding!