Microsoft MakeCode

Makecode feature idea! (Tilemap Variables)

I came up with (and edited some photos) to make a concept which could be in Makecode. When making a game, I’ve always wanted to store variables on specific tiles on a tilemap (and not have to make like 2 million different tiles that I have to go through to get one tile). This feature would be especially useful for world maps. I made some concept art:

Welllllllllllll…you could just place a sprite at a location and when you overlap with it check the data on the sprite instead.

You could use 2 lists, (location object and data) but you couldn’t compare 2 location objects directly as location objects aren’t singletons/primitive types. You would have to compare the col and row of the locations (like (location1 [column]) == (location2 [column]) && (location1 [row]) == (location2 [row])) and then use the index of that location to index into the data array.

But I’m pretty sure Tiled tilemaps can have data on them as well which would be cool in Arcade!

1 Like

Yes, great request @Kiwiphoenix364 and great suggestions @UnsignedArduino!

One other idea is to use the pixels of an image to store 2D data that corresponds to the tiles in a tilemap.

First, you’d create an image of the same size as the tilemap. With 16 colors, you can reserve specific colors to mean specific things and paint the pixel x / y of the image to store the corresponding data for the col / row of the tilemap.

Then, you’d use a similar handler as in your mockup, but adjust your if to test if picture color at x, y is equal to your value — though I think you have to use a number (0-15) when you’re checking equality with a color.

I started (and abandoned :sweat_smile:) a Final Fantasy 1-style game, where the random enemy encounters on the overworld would look up the difficulty of the encounter based on a supplemental image-based data source using a similar technique.

1 Like

Is there a way with this method to have more than 16 levels on one world map?

Since images only support 16 colors, that’s kind of a hard limit without resorting to additional variables/storage to track more info. But there are definitely ways you could do it.

One way—if for instance you have a few special places that need custom support (dungeon locations or something), and those are what push you over 16 different values—would be to reserve a value to mean “look at the actual tile instead of the picture data”. Then you could create custom tiles to support a longer list of “special” behaviors and keep 15 values for the more general cases.

Or if you really just need to store more than 16 and you want to use images to encode all the additional data, you could use two images + a little math to get to 256 different values (or higher):

To make the two images you’d want to take your full number and do two different math operations to figure out each image’s color value:

img1 pixel value = floor( full value / 16 )
img2 pixel value = full value % 16

[floor means round down, or just take the whole number part; % means take the remainder of the division—the Windows calculator has a “Programmer mode” that’ll automatically do integer division and also supports the % operator]

Then to compute the full value in the game:

full value = img1 pixel value * 16 + img2 pixel value

That said… this would be a pain to maintain while developing a game :sweat_smile:. I’d strongly recommend trying to use fewer than 16 values, but I’m including the explanation here to prompt some ideas…

Hopefully at least some of that makes sense!

1 Like