I'm doing some physics with vectors. Right now I use vectors for Location,Speed,Acceleration and Force.
If I where to write a function which for example creates an object at X,Y I could use a Vector instead:
Function CreateCar(X,Y)
Or
Function CreateCar(V:Vector)
To utilize this I would call the functions respecitvly:
CreateCar(X,Y)
and with vectors:
CreateCar(Location)
I think it would be nice to make my functions accept both because sometime I might want to not use vectors. Is there a smart way to do this with as little duplicate code as possible? Can I make a Function which accepts either a vector or a X,Y poss. I have a feeling there is a ultimate way of doing this in some advanced OO-way but I don't really know.
btw I have the vectormath working so if anyone would be interested in it I could post the library.
If I where to write a function which for example creates an object at X,Y I could use a Vector instead:
Function CreateCar(X,Y)
Or
Function CreateCar(V:Vector)
To utilize this I would call the functions respecitvly:
CreateCar(X,Y)
and with vectors:
CreateCar(Location)
I think it would be nice to make my functions accept both because sometime I might want to not use vectors. Is there a smart way to do this with as little duplicate code as possible? Can I make a Function which accepts either a vector or a X,Y poss. I have a feeling there is a ultimate way of doing this in some advanced OO-way but I don't really know.
btw I have the vectormath working so if anyone would be interested in it I could post the library.