Beispiel #1
0
        public static void DrawAll(GameState state, SpriteBatch spriteBatch, Camera gameCamera)
        {
            BasicEffect effect = Fireball.GetEffect(state.GraphicsDevice);
            effect.Projection = gameCamera.ProjectionMatrix;
            spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, effect);

            foreach (Fireball ball in state.Projectiles)
            {
                Vector3 viewSpacePosition = Vector3.Transform(ball.Position, gameCamera.ViewMatrix * Fireball.World);
                Vector2 locationOffset = new Vector2(viewSpacePosition.X - (Fireball.Texture.Width / 2) * Fireball.Scale, viewSpacePosition.Y - Fireball.Texture.Height * Fireball.Scale);
                spriteBatch.Draw(Fireball.Texture, locationOffset, null, Color.White, 0, Vector2.Zero, Fireball.Scale, 0, viewSpacePosition.Z);
            }
            spriteBatch.End();
        }
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     ground = new GameObject();
     gameCamera = new Camera();
     boundingSphere = new GameObject();
     bullets = new List<Bullet>();
     base.Initialize();
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            TouchPanel.EnabledGestures = GestureType.Tap;
            gameCamera = new Camera();
            frameRate = new FrameRateCounter(this, new Vector2(0, 0), Color.Wheat, Color.Wheat);
            gameState = new GameState(Content, GraphicsDevice);

            base.Initialize();
        }