How to create tilemap from image

Godot 4.2

How to create tilemap from tiny image?

Hi! I’m making a new project and messing with the tilemap class, let’s say i’m making a map without the Tilemap, I’m using a tiny Image with colors

I want to map the tiny map into a 16x16 tilemap and map those colors into a specific tile, like, red for platform A, blue for platform B, etc, etc. Is there any way to do this in Godot 4? I’ve seen some tutorials but they are in Godot 3

The map imagem_2024-02-16_012718149

The Atlas (I’m currently using a Cave Story Tileset just as a placeholder, i’ll change it later)
(Aaaand i just learned that new users like me can only send 1 image so here’s an Imgur link for the atlas lol)

Here’s the code I already tried doing, but it doesn’t appear at all (the code I found is from Godot 3, soooo I don’t know what to do)

extends TileMap

@export var Map : Texture2D
@export var Colors : PackedColorArray

func _ready():
	for x in Map.get_width():
		for y in Map.get_height():

func TileGen(x:int, y:int):
	var data = Map.get_image()
	var pixelColor = data.get_pixel(x,y)
	if pixelColor.a == 0: return
	for item in Colors.size():
		if Colors[item].to_html(false) == pixelColor.to_html(false):


Anyways, thanks for reading and waiting for some answers :slight_smile:

this sounds like an unnecessary headache. especially if you are new to godot. have you tried godot’s tilemap and tileset editor?

I’m trying to use that very TileMap help for my game, but it’s not working.
I have a tilemap set up in a single image. I was able to import it as a “tile”, but it’s not breaking it up into the 1,000 tile images that are in the file. How?!

Godot 4.2.1

try this

1 Like

Ok, that’s helpful, but …
It references an eraser and 3 dots on the tile tab which my 4.2.1 doesn’t have.
Oh my word! This thing is so dynamic that you have to have the exact right set of everything to even see the options.
What a cludgy mess!

My tilemap image is huge. There doesn’t seem to be anyway to scroll around the image to deal with everything. As I zoom in and out, it’s stuck in the middle of the image.

Yes, I tried, but just experimenting more of this feature just for fun, thanks :slight_smile: