#Edit tilemap generated through code?

2 messages · Page 1 of 1 (latest)

ionic pasture
#

I am generating a tilemap using code. Is it possible to see the tilemap in the editor before I run the game so I know where to place certain other nodes on the map?
The idea is I'm trying to make circular arena and I cant find any other way to go about it. the code I used is below.
I can only see the tilemap when I run the game. Is there a way to see it in the editor with the code so I can add stuff like trees and chests and walls?

func _ready():
    make_tilemap_circle(Vector2(0, 0), 150, Vector2i(1,0));
    make_tilemap_circle(Vector2(0, 0), 100, Vector2i(0,0));
func make_tilemap_circle(center_position, radius, tile_atlas):
    # The right half of the circle:
    for x in range(center_position.x, center_position.x + radius):
        # The bottom right half of the circle:
        for y in range(center_position.y, center_position.y + radius):
            var relative_vector = Vector2(x, y) - center_position;
            if (relative_vector.length() < radius):
                self.set_cell(0, Vector2i(x,y), 0, tile_atlas);
        # The top right half of the circle
        for y in range(center_position.y - radius, center_position.y):
            var relative_vector = center_position - Vector2(x, y);
            if (relative_vector.length() < radius):
                self.set_cell(0, Vector2i(x,y), 0, tile_atlas);

cut down the code in half because of limit

cosmic dagger