Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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)
    {
        triangle.Update(MathHelper.ToDegrees(e.Attitude.Yaw));
        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

1 Answer 1

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

 
discard

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.