• 2D
  • How to make a texture if using the CODE

Need logics of destruction for all tiles, but Tilemap does not allow this to be done. All that's found is the function draw_texture, but I absolutely do not understand its logic. Please, help

Here's how you get a texture entirely in GDScript if I remember correctly. (These steps should work, but are untested):

1| Make a ImageTexture using ImageTexture.new() 2| Call ImageTexture.load(path_to_file) on your newly created texture, passing in the path to the image you want to load 3| On your node's draw function, pass in the image texture as the first argument in draw_texture 4| Then the texture should draw at the given position, with optional color modulation and normal mapping if you pass those in.

You'll likely want to use draw_texture_rect or draw_texture_rect_region though if you are wanting to draw tiles, that way you can store all of the textures for your tile(s) in one image. In either of those functions you just need to pass an additional argument to them so it only draws a portion of the texture.

Sorry guys. I just now downloaded the godot and did not cut straight away. Here is my solution func _map_create(): if (gameStart): for k in mapSize: var openspace = preload("res://open_space.tscn").instance() openspace.position = Vector2(x, y) get_parent().add_child(openspace) x += 32 if (x >= mapWidth): x = 0 y += 32

(but I'm fixing this shit now) ^