I am trying to make a game using JavaScript. I am currently working on making gravity. What I need is to make an infinite loop. However, I know that if I don't use a break statement, the browser will crash. Is there any way I can implement a break statement that will only happen when I specify?
Here's my current loop:
for (i = 0; i < Infinity; i++) {
if (moveY > 300) {
moveY = moveY - i * 2 + 3;
move(moveX, moveY);
} else {
i = 0;
}
}