I am working on a project where a figurine is jumping, and at the moment of the jump on a platform, it will stop.
platforms.forEach((platform) => {
if (
player.position.y + player.height <= platform.position.y &&
player.position.y + player.height + player.velocity.y >=
platform.position.y &&
player.position.x + player.width >= platform.position.x &&
player.position.x <= platform.position.x + platform.width
) {
player.velocity.y = 0;
}
});
To define different platforms, I used an array.
My question is, how can I make a pop-up window with a message when a player. velocity.y = 0;
And after it happens, the window will close, and the movement starts again
Also, the first two elements of the array should be excluded because they create the running platform.
This is the code I try to use, but after the window is open, it will open again and again.