I've been working on creating a JavaScript game and am currently tackling the challenge of implementing gravity. One crucial aspect I need to address is creating an infinite loop without causing the browser to crash. Is there a way for me to include a break statement that only triggers under specific conditions?
Below is the current loop I have:
for (i = 0; i < Infinity; i++) {
if (moveY > 300) {
moveY = moveY - i * 2 + 3;
move(moveX, moveY);
} else {
i = 0;
}
}