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
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():
TileGen(x,y)
func TileGen(x:int, y:int):
var data = Map.get_image()
data.get_pixel(x,y)
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):
set_cell(0,Vector2i(x,y))
pass
pass
Anyways, thanks for reading and waiting for some answers