コード例 #1
0
ファイル: GameplayScreen.cs プロジェクト: ctoneal/asteroids
        /// <summary>
        /// Create a new bullet coming from the ship
        /// </summary>
        private void FireBullet()
        {
            Bullet newBullet = new Bullet(Game);
            Vector2 velocity = new Vector2((float)Math.Cos(ship.Rotation + (float)MathHelper.PiOver2), (float)Math.Sin(ship.Rotation + (float)MathHelper.PiOver2));

            velocity.Normalize();
            velocity *= 6.0f;

            newBullet.Velocity = velocity;
            newBullet.Position = ship.Position + newBullet.Velocity;

            bullets.Add(newBullet);
        }