How to expand a tilemap using code?

So, i want to expand my tilemap by a variable. I know shocker, read from the title.
I have tried to look into the tilemap.g.ts but i don’t understand how i woud utilize this:

tiles.createTilemap(hex`14000f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`, img`
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . 
`, [myTiles.transparency16], TileScale.Sixteen);

And isn’t ‘hex’ color code? I thought hex codes were

‘# 00 00 00’

Is anyone able to expand tilemaps with code?

1 Like

What do you mean by “expand by variable”.
Also, HEX is short for Hexadecimal, a numbering system with digits from 0 - 9 and A - F (10 - 15), sixteen digits in total, hence the hex.

In web development, (and pretty much everywhere else) hex numbers tend to be utilized for the purpose of storing color. That’s because color is stored in the RGB format (red, green and blue) where every color is a value between 0 - 255. (256 total). Since 256 combinations can be represented by 2 hex bytes (for example - 2F would represent 47 in the decimal system).

Adding three of these bytes would give you a format such as xx (red) xx (green) xx (blue) like you denoted. So, while it can be used for storing colors with 6 hex digits, you can have as many as you want, letting you store data more efficiently.

In Arcade, it’s common use since a color can be represented using a single hex digit (because there are 16 colors). I hope this clears that up

1 Like

So i kinda went away from my question in the post. My question was how to expand a tilemap in code. Do you know how?

1 Like

I don’t know what “expanding a tilemap in code” would mean, as I stated here

Can you clarify more?

1 Like

To get a clue of build a tilemap with code, see the “tilemap.g.ts” file in your projet, after created a tilemap.

1 Like

Lets say i have a tilemap of the size 3, 3.
And i wan’t to expand the tilmap by 0, 7 in an on Game update.

That is what i want to do

1 Like

I have already tried looking into it but don’t understand anything :sweat_smile:

Resize tilemap is neither supported with block, nor with codes.

So I suggest, prepare a tilemap big enough at beginning, and set tiles and walls in it at runtime.

Or with code, create a new tilemap(TilemapData object actually), just like codes in tilemap.g.ts.
The first parameter (hexxxxxxxxx), is a buffer object, which first 2 byte is width, following 2bytes is height, and all rest bytes are the index of tiles image in the array of tile set(the 3rd parameter). For example:

const newData=Buffer.create(4+newCol*newRow)
newData.fill(0)
newData.setNumber(NumberFormat.Int16LE, 0, newCol)
newData.setNumber(NumberFormat.Int16LE, 2, newRow)
const newTM= tiles.createTilemap(newData, ...)

newCol and newRow are the size of new tilemap.