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
.