Help to understand directions of sprites in XNA
Posted
by
3Dkreativ
on Game Development
See other posts from Game Development
or by 3Dkreativ
Published on 2012-07-10T20:51:27Z
Indexed on
2012/07/10
21:25 UTC
Read the original article
Hit count: 176
XNA
If I want to move a sprite to the right and upwards in a 45 degree angle I use
Vector2 direction = new Vector2(1,-1);
And if the sprite should move straight to right
Vector2 direction = new Vector2(1,0);
But how would I do if I want another directions, lets say somewhere between this values? I have tested with some other values, but then the sprite either moves to fast and or in another direction than I expected!? I suspect it's about normalize!? Another thing I have problem with to understand.
I'm doing a simple asteroids game as a task in a class in C# and XNA. When the asteroids hit the window borders, I want them to bounce back in a random direction, but I can't do this before I understand how directions and Vector2 works. Help is preciated! Thanks!
© Game Development or respective owner