Godot Version
Godot Engine 4.2.1
Question
How I can use the fill with code? It is like set_cell
I want to fill a white islands, because I vant to separate their on continents
Godot Engine 4.2.1
How I can use the fill with code? It is like set_cell
I want to fill a white islands, because I vant to separate their on continents
Although I have no idea how the code is, I assume it would be the following:
The code could be something like this
for tile in tilemap.get_used_cells(0): # I assume the cells are on layer0
var tiledata = tilemap.get_cell_tile_data(0, tile)
if tiledata == # however you distinguished the white islands
tiledata.modulate = Color.YELLOW # or something
I donβt understood βtiledata==β. I checked, if tile is land, then simply set a white color
if get_cell_atlas_coords(0, tile_position) in list_land_tiles:
list_continens_tiles.append(tile_position)
set_cell(4, tile_position, 2, Vector2i.ZERO)
Does this do what you want it to do?
if get_cell_atlas_coords(0, tile_position) in list_land_tiles:
list_continens_tiles.append(tile_position)
set_cell(4, tile_position, 2, Vector2i.ZERO)
var cell = get_cell_tile_data(4, tile_position)
cell.modulate = Color.WHITE
Thank you for your help, but i get
(cell.modulate = Color.YELLOW)
I understood how do it
var t = 1
for tile in list_continens_tiles:
if get_cell_atlas_coords(4, tile) == Vector2i(0, 0):
fill_continents(tile, Vector2i(t, 0))
t += 1
func fill_continents(pos : Vector2i, colot_tile : Vector2i):
var stack = [pos]
var visited = []
while stack.size() > 0:
var position = stack.pop_back()
# ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ, Π΅ΡΠ»ΠΈ ΡΠ°ΠΉΠ» ΡΠΆΠ΅ Π±ΡΠ» ΠΏΠΎΡΠ΅ΡΠ΅Π½
if position in visited:
continue
# ΠΠ°ΠΌΠ΅Π½ΡΠ΅ΠΌ ΡΠ΅ΠΊΡΡΠΈΠΉ ΡΠ°ΠΉΠ» Π½Π° Π½ΠΎΠ²ΡΠΉ
set_cell(4, position, 2, colot_tile)
# ΠΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΎΡΠ΅Π΄Π½ΠΈΠ΅ ΡΠ°ΠΉΠ»Ρ
for offset in list_vectors:
var neighbor_position = position + offset
if get_cell_atlas_coords(4, neighbor_position) == Vector2i(0, 0):
stack.append(neighbor_position)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.