Vectors

Blitz3D Forums/Blitz3D Beginners Area/Vectors

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm doing a 2d physics simulation and as such I need to use vectors a lot. However I'm new to programming so I don't know the best way to implement them. For instance I tried to make a function that you pass two vectors to and it return their sum as a vector.

Function Add_Vectors.Tvector(v1.Tvector,v2.Tvector)

u.Tvector = new Tvector
u\x = v1\x + v2\x
u\y = v2\y + v2\y
return u

End Function

Now I realise that this is just passing the memory address of the new vector just created so every time this is called it creates a new Tvector. Is there a way to use nice functions like this properly?

Also, is it bad programming practice to continually create/delete objects. This is what I intended to do for my collision sorting algorithm.