Reputation: 31
How can i determine the x and y coordinates of a pygame.math.Vector2
object?
self.position = Vector2(x, y)
This is the Output from x and y in Vector2:
[5,14.5]
Upvotes: 2
Views: 1926
Reputation: 101052
From the docs:
The coordinates of a vector can be retrieved or set using attributes or subscripts
v = pygame.Vector3() v.x = 5 v[1] = 2 * v.x print(v[1]) # 10 v.x == v[0] v.y == v[1] v.z == v[2]
Multiple coordinates can be set using slices or swizzling
v = pygame.Vector2() v.xy = 1, 2 v[:] = 1, 2
Upvotes: 4