https://makecode.com/_Usqg3wMdoFzV
Students game - I know the code is probably very buggy but she is only 10! I can’t figure out what she has done for the last level - It takes a minute to load the last tile map…Any help?
Thanks!
https://makecode.com/_Usqg3wMdoFzV
Students game - I know the code is probably very buggy but she is only 10! I can’t figure out what she has done for the last level - It takes a minute to load the last tile map…Any help?
Thanks!
I don’t think I see it taking a minute, but there is a bit of a delay that I see (from 0-4 seconds) – the reason is because of these pauses in the forever loop:
combined with the tilemap being set in that portion:
This means that whenever it spawns an enemy, it won’t check if it should move to the next map until 4 seconds has passed.
The easiest fix is to split those two if (level = ?)
's into their own forever loops:
This will cause it to be checked every frame, which means that the level will move on on the next frame instead of up to 5 seconds later.
There’s still a slight issue here though, which is that the level transition happens after a frame has finished – it’ll still flash on the old tilemap momentarily before ‘moving on’, as it draws the screen after all the movement has finished / before the forever loop runs again. Easiest fix is to move the portion that sets the tilemap into the overlap that is causing the level to change;
the way I’d think of it is that you usually only want to have things in forever loops that you want to happen every time it loops, and you don’t really want to reset the level every loop – you just want to spawn the enemies, so it’s best to move setting the level out of the loop. This will also let you change where you want the player to spawn in the next level, as right now it will spawn in the location set for the level you are leaving~