Godot Version
4.2.1
Question
I am drawing procedurally generated tiles with the draw_rect() function, but the tiles are not drawing where they say they are. even printing the position before drawing, like this:
rect = Rect2(position, tile_size)
print(position)
draw_rect(rect, col)
it still prints (0, 0) as the position, but they render way off at something like (1000, 200). everything in the scene is at the position (0, 0), so there should be no reason for this to happen. here is the complete tile rendering code (WARNING: BAD CODE):
extends Control
var map_size = Vector2(20, 10)
var tile_size = Vector2(2, 2)
var rect = 0
var col = Color.SADDLE_BROWN
@onready var world_gen = $“…/WorldGen”
Called when the node enters the scene tree for the first time.
func _process(delta):
queue_redraw()
func _draw():
position = Vector2(0, 0)
for x in range(0, world_gen.width):
position.y = 0
position.x = x*tile_size.x
for y in range(0, world_gen.tile_map):
rect = Rect2(position, tile_size)
print(position)
draw_rect(rect, col)
position.y -= tile_size.y
please help, I am going insane.