Adding / mutliplying objects

Monkey Forums/Monkey Programming/Adding / mutliplying objects

Raz(Posted 2012) [#1]
In XNA / C# I am able to add vectors to vectors to create a product vector.

Local v1:Vector2 = Vector2.Create(10,10)
Local v2:Vector2 = Vector2.Create(5,-5)
Local v3:Vector2 = v1 + v2

Print v3.x
Print v3.y

The above would output

15
5



Is this possible in Monkey?


AdamRedwoods(Posted 2012) [#2]
No operator overloading in Monkey allowed (yet???).

You have to make your own:
Class Vector2
   Field x#, y#
   
   Method Add(v:Vector2)
     x+=v.x; y+=v.y
   End
End

v1.Add(v2)



Raz(Posted 2012) [#3]
Ahh ok, yeah that's what I am doing at the moment.

Cheers Adam