I have a bunch of objects that when they fall out of screen, it wont stop subtracting.
for (var i = 0; i < maximum_number_objects_spawned; i++){
if (objects[i].y > game_height){
lives = lives - 1;
}
}
For context, I am using a gravity engine to pull these objects down, so it isn't really applicable to use an if "objects[i] is equal to the world_height" statement. Here is something I tried that didn't work:
for (var i = 0; i < maximum_number_objects_spawned; i++){
lives_not_subtracted = true;
if (objects[i].y > game_height && lives_not_subtracted === true){
lives = lives - 1;
lives_not_subtracted = false;
}
}
This still did not work and rather continued to subtract lives infinitely. I am curious as to see why my second method did not work, although it looks as if it should've.