AliAbdulKareem said:
btw, what is your reasoning behind using Perp() ? like does it happen a lot you want something perpendicular?
I have used this to implement a support polygon for balancing ragdoll. The perpendicular stuff is used to find if a point is inside or outside the polygon, and to find the closest point on the polygon. The same things would become necessary to handle collision and velocity reflection against walls which are not axis aligned.
In general you always need perp in 2D when you would use the cross product in 3D, i would say. So it should be there.
But Length() and Normaize() should be added ofc.
Though, not everybody does this. In the Physics Engine i'm using, i need to write this to get the length of a vector:
float mag = sqrt(v.Dot(v).AsFloat());
which is really cumbersome and annoying. ; )
AliAbdulKareem said:
I would add my voice to avoid using a math library and avoid using vectors even at this point, just get it to work for now.
Yes, but also no.
Phil runs against a wall because he uses just global variables and spaghetti code for everything. He could not understand my simple example code of a Space Invaders game because i have used a struct for enemies in some array or std::vector.
So he must learn about using data structures to get over the wall. Otherwise he'll remain stuck.
And those vec2, vec3 and matrices we use are the very best example to show the incredible advantage of using small structs or classes. It's the perfect exercise, but sadly the math concept gets in the way eventually. And i want to teach data structures, not yet math.
So i agree it's best to go without it first, but then eventually update the working Pong game to use Vec2 instead x,y variables, once it works.
Or eventually do Space Invaders first, still focusing primarily on a data structure to handle many enemy sprites.
But when it comes to Breakout, using Vec2 for math can reduce complexity a lot and i recommend it at this point.
(Btw, don't confuse vec2 or vec3 with std::vector. Completely different things which have nothing in common.)