Microsoft MakeCode

Arcade Advanced Stream #104 - Zoom Zoom

Join @hassan and me as we make a city tilemap with the 8x8 tileset! Here’s the Javascript you need to copy and paste into a new “custom.ts” file to make a new 8x8 tilemap block:

namespace custom {
//% blockId=tilemap_editor_eight block=“set tilemap (8) to $tilemap”
//% weight=200 blockGap=8
//% tilemap.fieldEditor=“tilemap”
//% tilemap.fieldOptions.decompileArgumentAsString=“true”
//% tilemap.fieldOptions.filter=“tile”
//% tilemap.fieldOptions.tileWidth=8
//% tilemap.fieldOptions.taggedTemplate=“tilemap”
//% blockNamespace=“scene” group=“Tiles” duplicateShadowOnDrag
//% help=tiles/set-tile-map
export function setTilemap(tilemap: tiles.TileMapData) {
scene.setTileMapLevel(tilemap);
}
}

Watch the full stream here. Sorry the audio is echo-y :sob:. Hassan is fine, if you want to listen to his cooking journey!: https://youtu.be/RSDBnChJCnw

Check out the code below:

The MakeCode Arcade Advanced stream happens weekdays at 1:00 PM PST on twitch.tv/msmakecode

1 Like

Is there a way to make it 32 by 32?

yes there is! You can use that same bit of Javascript, but for the .tileWidth setting, change it from 8 to 32. And for clarity, you can rename the block to be blockId=tilemap_editor_thirtytwo and then block="set tilemap (32) to $tilemap"

Finnnnnnnnnnnnnnnnnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaallllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy!!!

I always wanted to do that.

1 Like

I have always been wondering, how do you make screen icons?

ooo what do you mean by screen icon?

There is a screen icon in that game at the bottom of the left hand side

I think @LCProCODER means that speed display you made

Yeah…

OOOOOO yeah so that’s actually just a sprite! I used the “relative to camera” flag to stick it to the bottom of the screen

1 Like

Something like this?https://makecode.com/_6UsRyodE5i3T

1 Like

yeah!!! that looks awesome :smiley:

1 Like

Do tilemap tile sizes have to be powers of two (8, 16, 32…)? I think I saw some old posts from @jwunderl (like this one) that mentioned there are some optimizations that don’t support arbitrary sizes…

It’s pegged to powers of two, lots of bit shifting in the implementation for performance on hardware

2 Likes

Wait… So does this let you make smaller 8x8 walls?

yupyup!

What about 2*2?

I might be wrong, but technically speaking, isn’t every number a power of two? For example, 2^1.5849625 = 3. Again, I might be wrong.

@Agent_14 right, 2 * 2 = 2 ^ 2 so it would be possible to make a tilemap of 4x4 tiles, though it’s untested / likely slow on hardware (I would suspect it to would work fine in most cases / you shouldn’t run into any weird wall handling cases. 2^1 might work just fine as well, but that would be bit iffy with wall hitting / bumping as there are some cases we try to handle clipping with 1 or 2 pixel adjustments).

@omnisImperium powers of {n} is typically defined to be the set of results of all expressions n^i where i is an integer and i >= 0 - you’re right that you can always put another expression / non integer as the exponent, but you wouldn’t typically call the result a power of the base unless it were a nonnegative integer.

In this case that is true as well, as the technical reason for it is that we use bit shifting for faster calculations for hardware, which is only defined for integers / anything after the decimal will get truncated during the operations so you wouldn’t be able to meaningfully use a scale of 2.5 / it would probably behave exactly the same as a scale of 2, with potentially a few bugs due if there are some expressions that don’t implicitly change it to be an int.

1 Like