Microsoft MakeCode

Force screen update

Would it be possible to include a block that would force Arcade to redraw the screen? Or even a JavaScript command, like game.update_screen()? So we don’t have to include pause(100) whenever we want to update the screen, like during a resource-intensive function that’s displaying a progress bar. (For me, that’s calculating 20 different paths over a 64x12 tilemap using Joey’s A* extension. It’s actually pretty slow when the tilemap is that big, which is understandable.) Or will even calling pause (1) update the screen?

1 Like

When I used sprites and stuff I think pause(0) or pause(1) worked but that was a while ago. I could be wrong.

1 Like

Maybe you can explain what you are trying to achieve? I don’t quite understand why you would pause just to update the screen, since the screen IS being updated every few milliseconds. The amount of time between a ‘game update’ is not fixed, as that is dependent upon the hardware and sprites and events it has to process, but in each ‘update’ of the scene, the following occurs:

Game Loop (makecode.com)

1 Like

If you have a resource intensive function running that doesn’t have any delays in it, the screen won’t update unless I put in a delay. For example, I manually draw a progress bar to track it. If I don’t put in the delay, it goes from 0 to 100 after 20 seconds instantly. If I put in a delay, it goes smoothly from 0 to 100 after around 25 seconds.

1 Like

You could use a status bar like this.

I think the default value of the status bar is 100, and every 100 milliseconds I change the value by -1. This should mean that the game ends after approximately 10 seconds.

1 Like

The problem isn’t the status bar - my drawing routines aren’t being called (which is a draw on z index handler in Joey’s sprite utilities) during my resource intensive function, unless I put in a delay between each step of the function.

1 Like

And my status bar ain’t cosmetic. :slight_smile:

Hmm. Why does it take an extra 5 secs

1 Like

I’ve checked the time difference and it actually takes around 10 seconds with the delays and 7 seconds without the delays. (Moved the code around and benchmarked it) This is because I have 3000 ms delay split over 30 iterations. (100 ms per sprite) Arcade takes this time in between to update the screen.

1 Like

I know there is an extension for running code in the background. Could that help here?

1 Like

It’s called Timers, and it shaved off 1 second. :slight_smile: (9 seconds left!!!)

2 Likes

pause(50) and pause(20) also work but there is not difference under 50 ms. (7.5 seconds!)

2 Likes