Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a simple asteroids 2D game with XNA so I can learn more on game development, I've started by reading this tutorial and, with my previous knowledge from developing Windows Phone applications, I've started changing the code. I've designed a simple isosceles triangle that is rotated with the accelerometer, like this:

private void CurrentValueChanged(MotionReading e)
    // Check to see if the Motion data is valid.
    if (motion.IsDataValid)
        System.Diagnostics.Debug.WriteLine("Yaw: " + MathHelper.ToDegrees(e.Attitude.Yaw));
        System.Diagnostics.Debug.WriteLine("Angle: " + triangle.getAngle());

The triangle.Update just changes the batch.Draw rotation parameter.

I'm also creating a "bullet", when the user clicks on the screen, using a circle texture, what I want to know is how I can point this "bullet" to the direction that the triangle sprite is heading.

PS: The triangle "point", where the bullet should be fired, is exactly the width / 2.

share|improve this question

That's (below) standard geometry: As you rotate the triangle from its initial position using the angle you got from user input, you can also define the shooting vector direction MC where M is the middle of the base (width/2) and C is the opposite vertex of the triangle. Rotating the triangle will automatically rotate the shooting direction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.