This 'Voronoi Sprites' program will show that there is a bug in MicroStudio. I don't know if it's a parsing error or something more complicated.
- Run this program.
- The Voronoi diagram is displayed.
- Start editing the code, for example comment out code lines 28
// screen.drawSprite ("sprite1." + temp, x, y, 4, 4)
- The diagram is not drawn - this is what you expect.
- Now uncomment code line 28.
- Oooooooh, there's just a big green square.
The same error occurs in MicroScript 1.0, MicroScript 1.0 + Transpiler, MicrosScript 2.0 beta. You will get the same result if you stop the program while commenting. The error occurs in Firefox 101 and Chrome 102.
This error is very hard to spot because sometimes you comment a line of code in one place and something you don't touch stops showing (doesn't work). If you are new to programming, you don't know what is happening or why.
I also have a second 'Sound' code - instability.
- If I run it by clicking the mouse on the "Run project" button - the model melody is played - at the beginning.
- Don't click anywhere else. Just keep pressing the "A" key when the melody is over. The computer plays the same tune in the same way over and over again.
- a) Click now on the source code. b) You don't need to add anything to the code or comment on the line. c) Now click on the place where the program works - the right side of the page.
- Press the "A" key - now the music is sped up. It is also tearing (it has distortion).
If you start the program with the "Restart project" button and quickly click on the field where the program works, the music will stop playing immediately! Why ? . After pressing the "A" key - playback is accelerated.
midi = "sin loop 2 C2 C F G G G F end" init = function() runPlay = false firstPlay = true end play = function( string ) audio.beep( string ) end update = function() if (keyboard.press.A and ( not runPlay )) then runPlay = true print( 'Press A ') end end draw = function() if firstPlay then firstPlay = false play( midi ) end print( system.time() + ' '+ system.fps + ' Press A to play') if runPlay then runPlay = false audio.cancelBeeps() play( midi ) end end