0

I am trying to add sprites to a game I am currently working on. I have sprites for north, south, west & east directions. I've already found how to get a direction from degrees, the problem is that I can't seem to calculate the right amount of degrees (0° to 360°) from a normalized velocity vector, called heading. Check figure 1 below for my velocity vector, my heading vector is a normalized clone of this vector.

What I want to achieve is that:

  • A property degrees: returns the right amount of degrees, based on a current heading/velocity vector.
  • A method receiving degrees as parameter, which in turn can return a direction which I can use when drawing my sprite.

Velocity vector

Figure 1: my 2D velocity vector

My code for calculating the heading vector:

Vector2D heading = Velocity.Clone.Normalize();

I am also not sure if using a heading vector is necessary, so if it's possible or preferred to use the velocity vector, please tell me and include this in your answer.

J. Doe
  • 101
  • 10

0 Answers0