I have this data:

	[0, 0],
	[-1, 0],
	[1, 0],
	[0, 1]
]```
I'm trying to find a way to "rotate" it around the first node, so it would become this:
```[
	[-1, 0],
	 [0, 0],
	 [0, 1],
	 [0, -1]
]```
This is for a tetris game that uses individual "cells" to make up a block, and if I rotate the entire block, the shading on my cells gets messed up, showing that there's a light off to the side instead of above. This code turns it into the colliders and cells:

#TileData is the above mentioned array. for child in get_children(): child.queue_free() if !tileData || update_data: tileData = tileConf.data[type] for point in tileData.points: var cell = Sprite.new() cell.texture = preload("res://img/block/cell.svg") cell.modulate = tileData.color var col = CollisionShape2D.new() col.shape = preload("res://cellCollider.tres") var pos = Vector2(point[0], point[1])*36 col.position = pos col.hide() cell.position = pos add_child(col, true) add_child(cell, true)

I'm not sure this code is relevant, but maybe "rotating" them could work right in this function, and my rotation is a variable that's one, two, or three, called `turn`, because it's the best I could think of where 0 is up, 1 is left, 2 is down, 3 is right.

what could work: 1. change your array so that it holds actual Vector2 instead of an array 2. assume that the first position of your tile_data array is always the anchor of your shape 3. when rotating, simply use the built in function Vector2.rotated(PI/2) or Vector2.rotated(-PI/2) to replace every entry except the first one 4. voila, you have rotated every position clockwise/counterclockwise

They have to be recorded in their position relative to the one being rotated, so one cell 3 away from the first would be direction times 3. If it's right, it's 3 positions right of the first. If it's up, it's 3 positions up of the first.

11 days later

Thanks, @vinpogo ! In the end, I realized I was overwriting the array, so be sure to use Array.duplicate()!

if(val > 0):
		for item in someArray:
//If this is a poolVector2Array, don't use the following lines or the last 2, just replace item with vec in the for loop.
			var vec = Vector2(tile[0], tile[1])
			vec = vec.rotated(((-PI/2)*(val)))
			tile[0] = vec.x
			tile[1] = vec.y
a year later