How can I make the grid work well?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Drawsi

I just can’t seem to find a way to make it work well, it doesn’t work all the way on the far left.

Idk why - Album on Imgur

:bust_in_silhouette: Reply From: deaton64

When you say it doesn’t work on the far left, do you mean it’s not putting the sprite in the centre of the grid box or something else?

If it’s the first part of the above, and you know the coords of grid square… ie x = 10, y = 2, the do something like Vector2( (x * 64) - 32, (y * 64 - 32) ) - assuming that your grid starts at 1,1. That should put you in the middle of the grid square.

:bust_in_silhouette: Reply From: juppi

Try this:

func _draw():
	for x in range(1, grid_size.x, cell_size):
		for y in range(1, grid_size.y, cell_size):
			draw_rect(Rect2(x, y, cell_size, cell_size),, false, 1.0, false)