game.height keeps increasing?

Not sure if this should be posted in the newbie section… But I am a newbie… So… Yeah

Anyway, I’m currently running into a peculiar problem. I’m working on an Angry Bird-esque game, where the user fires a bomb at buildings, the “camera” follows the bomb as it flies and zooms out as it travels.

I’m currently working on a reset function, that respawns the bomb after you fired it, but I noticed that my game.height is increasing infinitely! I’m using print(game.height)  and notice that its at 660 at the start (which I find to be a weird number, but okay it works fine), but after I fire once it just increases and increases and increases.

This is my code for handling my “camera” (I call it a camera, but all I’m doing is move image groups across the board).

&nbsp;&nbsp;&nbsp;&nbsp;--Main loop &nbsp;&nbsp;&nbsp;&nbsp;function loop(e) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if hit == false then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local targetx = (- bomb.x + 100) \* game.xScale &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local targety = (- bomb.y) \* game.yScale &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if targetx\>0 then targetx = 0&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif targetx\<-400 then targetx = -400 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;game.xScale = 1 + (game.x\*0.0008) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;game.yScale = game.xScale &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;game.x = game.x + (targetx-game.x)\*0.25 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;game.y = (game.height - (game.height \* game.yScale))/2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("game height", game.height) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("---") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif hit == true then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;

This loop is run every frame, since it needs to calculate where the camera has to be at every frame. I dont think any other code needs to be posted, since none of the other code touches attributes from the game group.

To clarify, “hit” is to determine whether the bomb hit something or not, thus freezing the camera in place for a few seconds, before a new bomb is spawned and hit is set back to false.

Okay, I think I may have found the problem. I never realized that my “game” is actually my image group holding all my game elements, so if an element falls off the stage, it would continue to fall forever, thus increasing my game.height indefinitely

Is there any way for me to ignore items that fall outside a specified range? Or better, to delete them once they drop out of my game field? I’d rather not use invisible walls, since the game plays in an open world, so having blocks suddenly bounce back wouldn’t feel right.

Okay, I think I may have found the problem. I never realized that my “game” is actually my image group holding all my game elements, so if an element falls off the stage, it would continue to fall forever, thus increasing my game.height indefinitely

Is there any way for me to ignore items that fall outside a specified range? Or better, to delete them once they drop out of my game field? I’d rather not use invisible walls, since the game plays in an open world, so having blocks suddenly bounce back wouldn’t feel right.