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
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.
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.