Add map import option
I want to make a game with a big map system but each map is split into 32x32 tiles (for a chunk system). What I would appreciate is even just a really simple way to import maps, even if just a big list of tiles in a json file
{
"width":32,
"height":32,
"tiles":[0, 0, 0, "my_tile:0,0", "my_tile:1,0", "my_tile:2,0" ...]
}
While it is possible to create maps at runtime with maps.map.clone()
and maps.newMap.set()
, it would be slow and ruin the user experience.
yea thats it i think
Hey! I saw your post about the 32x32 chunk tilemap system. I think you can totally do it by loading tile data from JSON and placing tiles manually with map.setTile(), instead of using .clone() and .set() — it’s much faster and more customizable. I made a helper function that reads the JSON and places the tiles in the right spot. If you want, I can help tweak it to your system too!
I'm sorry but I don't quite understand what you mean. There is no function map.setTile()
.
And my map system requires me to have every map loaded and in the maps section before the game starts. I meant, before starting the game, I could load/initialize the maps by using .clone
(for a new map) and .set
(to put the tiles on the new map) but it would be slow and triple my project size.
Oops, Here's an easier and more efficient way to load maps in Microstudio from JSON tile data — without cloning pre-made maps or bloating your project size. Your JSON-style chunk format:
chunk_data = {
"width": 32,
"height": 32,
"tiles": [
0, 0, 0, "my_tile:0,0", "my_tile:1,0", "my_tile:2,0",
// ... continue until you have 1024 tiles (32 * 32)
]
}
Function to create a map from the tile list:
function createMapFromChunkData(data) {
let map = maps.create(data.width, data.height)
for (let i = 0; i < data.tiles.length; i++) {
let x = i % data.width
let y = floor(i / data.width)
map.set(x, y, data.tiles[i])
}
return map
}
Note: This uses the correct method → map.set(x, y, tile_id)
Store the chunks in memory:
chunks = {}
function setup() {
chunks["chunk_0_0"] = createMapFromChunkData(chunk_data)
// add more chunks as needed
}
Draw the current chunk:
function draw() {
maps.current = chunks["chunk_0_0"]
maps.current.draw()
}
You don’t need to use .clone() or .set() from pre-made maps.
This avoids tripling your project size and keeps everything in code or JSON data.
You can preload any number of chunks in setup(), and they’ll be ready when the game starts.
Later on, you can expand this system with JSON imports or dynamic chunk loading.
Let me know if you want an example chunk with full 32×32 data or want to build a chunk loader from a .txt or .json file too!
And also let me know whenever other help you need :)