Frogger game lagging after playing for a certain amount of time

I built a version of Frogger for my class. The game seems to work well except the problem is after the player get more than 5 or 6 frogs across the game lags and the entire browser seems to freeze. This only started happening when I added a check in the game where every 3 frogs the player gets across, the obstacles in the game speed up.

I am using clones to create the obstacles, but they delete once they glide off the stage. I thought the problem might be that too many clones are being created at once, but after monitoring the game there are never more than 3 of each clone at once. I looked though the other processes I am running, but cannot seem to figure out what is causing it to lag.

Here is a link to the game, any advice is appreciated!

Nice Frogger game!

You think you're deleting the "log" and "car" clones, but if you check our conditions you never are deleting any of them, and your game keeps producing more constantly:

frogger game script pic

What's the condition for deleting a clone? How could it be reached? You're moving the clone to x: 360, how could it ever become greater than 360?

You can see the clones piling up if you check the results of occasionally clicking on a my clones reporter and checking the result count:

That alone wouldn't be a big problem, Snap! can handle lots of clones, but your "game loop" block also keeps checking for collisions with any of those clones constantly, and since the clone count keeps going up those constant collision detections also keep growing exponentially.

Thank you so much! Pretty silly mistake on my part.

beat me to it

this happens a lot

Just a comment, here (log 1, log 2, car):
You can remove the if block like this:
The if block has no effect here, because at the end of the glide block, x was exactly equal to -316... ant the if was evaluated after the execution of the glide block

Another way of thinking:

nice game!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.