Microsoft MakeCode

Arrays that don't want to be arrays

I’m working on a little microbit arcade, where you select a game and play it (obviously), and the first game I’m making is snake, so I made two arrays to store the player’s previous X and Y coords for the tail, but the blocks I’m using to add the X and Y on seem to believe the array is a type ‘number’ as opposed to a type ‘number[ ]’. I have attatched a picture of the only two mentions of these arrays in the code.


How can I fix this?

3 Likes

Think you want something like this:
image

2 Likes

The pill-shaped insert at beginning returns the size of the resulting list, which is a single number. As @UnsignedArduino has shown, you probably want to use the connecting block version of insert at beginning, which is a little further down in the palette of blocks.

It’s a little confusing that there are two versions and that the one that returns the list length is above the one that’s probably more commonly used. It may be worth opening an Issue on the github repo to see if anyone is willing to either change the order, change the names, or move the one that returns the length to a ... sub-palette.

2 Likes