public void draw(SpriteBatch spriteBatch, Vector2 currentViewPort)
 {
     if (inside)
     {
         locationMap.drawMap(spriteBatch);
     }
     else
     {
         Vector2 renderPosition = new Vector2(objectPosition.X - currentViewPort.X, objectPosition.Y - currentViewPort.Y);
         spriteBatch.Draw(objectTexture, renderPosition, Color.White);
     }
 }
Example #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (currentPlayer.getIsDead())
            {
                string  gameOver = "A Zombie got your brains -  Game Over! ";
                Vector2 position = new Vector2((graphics.PreferredBackBufferWidth / 2) - (font.MeasureString(gameOver).X / 2), graphics.PreferredBackBufferHeight / 2);
                spriteBatch.DrawString(font, gameOver, position, Color.Red);
            }
            else
            {
                currentMap.drawMap(spriteBatch);

                currentPlayer.drawPlayer(spriteBatch);

                foreach (Zombie zed in zombies)
                {
                    zed.drawZombie(spriteBatch, currentMap.getViewport());
                }

                if (attacking)
                {
                    //spriteBatch.Draw(attackingWeaponTexture, attackingWeaponPosition, Color.White);
                    spriteBatch.Draw(attackingWeaponTexture, attackingWeaponPosition, null, Color.White, RotationAngle,
                                     attackingWeaponOrigin, 1.0f, SpriteEffects.None, 0f);
                }

                if (constructionMenuOpen)
                {
                    conMenu.draw(spriteBatch);
                }
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }