HELP! My 2nd Level Is Lagging

Hi there,

I have been working on a game about ocean pollution. To advance to the next level, the player must collect garbage and climb the platforms to arrive at the end of the tilemap.

  1. The game runs without lag in the first level, but when the player arrives at the second one, it is super laggy and the player can barely move. Does anyone have any ideas on how I can fix this? (By the way, I have been coding on a chromebook, so I don’t know if it is contributing to the lag??)

  2. I was also wondering how to restart at the level the player died in instead of returning to the very beginning of the game. I tried to code this, but it didn’t work for my second level. Here’s what I have:

  1. I programmed the player’s sprite (Scuba Diver-MC) to move when the arrow keys are pressed. However, sometimes it moves on its own and makes unusually large jumps. If you die in the first level, it will bring you back to that level and that’s when you will notice this glitch. It also frequently occurs in the second level of my game.

Here’s the link to my game:

Thank you!

The only thing I can say about the lag would be to limit the amount of sprites at any given time (maybe you could separate the trash collecting segment and the reef platforming section), you could also find a way to destroy the trash sprites (maybe a, destroy array of __ block). Along with that, try adding walls in the sorting part so the sprites don’t wander off-screen. You should also add some conditional statement to the when B button pressed command otherwise the code cant run. As for the moving on its own, I think that it might be the lag. I hope this helps even if just a little.