Reputation: 810
I want to do something like:
from pyray import Vector2
v2 = Vector2(1,2)
print(v2 * 10)
But I get:
TypeError: unsupported operand type(s) for *: '_cffi_backend.__CDataOwn' and 'int'
Same result if I multiple the vector with a float.
Is there a way to do this operation in raylib? I know I can do
v2 = Vector2(1,2)
print(v2.x * 10)
print(v2.y * 10)
but it's a bit annoying to write 2 lines instead of 1.
Upvotes: 0
Views: 117
Reputation: 13
Its not possible out of the box but you can write a helper function like this
from pyray import Vector2
def multiply_vector2(v, scalar):
return Vector2(v.x * scalar, v.y * scalar)
v2 = Vector2(1, 2)
result = multiply_vector2(v2, 10)
print(result.x, result.y)
Upvotes: 0