Ejemplo n.º 1
0
        } // end method MovePlayer

        /// <summary>
        /// This method draws everything the game needs to display
        /// (black background, player, invaders, shots, stars, score, lives left) onto the screen.
        /// </summary>
        /// <param name="g">The graphics object to draw onto.</param>
        /// <param name="animationCell">The number representing which picture of animation every invader should display.</param>
        public void Draw(Graphics g, int animationCell) {
            g.FillRectangle(Brushes.Black, 0, 0, boundaries.Width, boundaries.Height);

            stars.Draw(g);
            
            foreach (Invader invader in invaders)
                invader.Draw(g, animationCell);
            
            playerShip.Draw(g);
            
            foreach (Shot shot in playerShots)
                shot.Draw(g);

            DrawBombs(g);
            
            foreach (Shot shot in invaderShots)
                shot.Draw(g);


            DrawExplosions(g);

            DrawDeadInvaderScores(g);

            DrawShields(g);
            
            DrawScoreAndWaveProgress(g);

            DrawLivesLeft(g);

            DrawBombStatus(g);

        } // end method Draw
Ejemplo n.º 2
0
 public void Draw(Graphics g, int animationCell)
 {
     g.FillRectangle(Brushes.Black, boundaries);
     stars.Draw(g);
     using (Font font = new Font("Arail", 16))
     {
         g.DrawString(score.ToString(), font, Brushes.AliceBlue, new Point(8, 8));
     }
     for (int i = 0; i < livesLeft; i++)
     {
         g.DrawImage(Properties.Resources.player, new Point(boundaries.Width - (playerShip.Area.Width * (i + 1) + 5), 3));
     }
     foreach (Invader invader in invaders)
     {
         invader.Draw(g, animationCell);
     }
     playerShip.Draw(g);
     foreach (Shot shot in playerShots)
     {
         shot.Draw(g);
     }
     foreach (Shot shot in invaderShots)
     {
         shot.Draw(g);
     }
     if (explosions.Any())
     {
         foreach (Explosion explosion in explosions)
         {
             explosion.Draw(g, animationCell);
         }
     }
 }
Ejemplo n.º 3
0
        public void Draw(Graphics g, int animCell)
        {
            g.FillRectangle(Brushes.Black, boundaries);

            stars.Draw(g);

            foreach (Invader invader in invaders)
            {
                invader.Draw(g, animCell);
            }

            playerShip.Draw(g);

            foreach (Shot shot in invaderShots)
            {
                shot.Draw(g);
            }

            foreach (Shot shot in playerShots)
            {
                shot.Draw(g);
            }

            g.DrawString($"Wynik: {score}", new Font("Tahoma", 15, FontStyle.Bold), Brushes.Yellow, new Point(boundaries.X + 20, boundaries.Y + 20));
            g.DrawString($"Życia: {livesLeft}", new Font("Tahoma", 15, FontStyle.Bold), Brushes.Yellow, new Point(boundaries.Width - 120, boundaries.Y + 20));

            if (!playerShip.Alive)
            {
                g.DrawString($"GAME{Environment.NewLine}OVER", new Font("Tahoma", 100, FontStyle.Bold), Brushes.White, new Point(150, 80));
            }
        }
Ejemplo n.º 4
0
        // Draw is fired with each paint event of the main form
        public void Draw(Graphics graphics, int frame, bool gameOver)
        {
            graphics.FillRectangle(Brushes.Black, formArea);

            stars.Draw(graphics);
            foreach (Invader invader in invaders)
            {
                invader.Draw(graphics, frame);
            }
            playerShip.Draw(graphics);
            foreach (Shot shot in playerShots)
            {
                shot.Draw(graphics);
            }
            foreach (Shot shot in invaderShots)
            {
                shot.Draw(graphics);
            }

            graphics.DrawString(("Score: " + score.ToString()),
                                statsFont, Brushes.Yellow, scoreLocation);
            graphics.DrawString(("Lives: " + livesLeft.ToString()),
                                statsFont, Brushes.Yellow, livesLocation);
            graphics.DrawString(("Wave: " + wave.ToString()),
                                statsFont, Brushes.Yellow, waveLocation);
            if (gameOver)
            {
                graphics.DrawString("GAME OVER", messageFont, Brushes.Red,
                                    (formArea.Width / 4), formArea.Height / 3);
            }
        }
Ejemplo n.º 5
0
        } // end method MovePlayer

        /// <summary>
        /// This method draws everything the game needs to display
        /// (black background, player, invaders, shots, stars, score, lives left) onto the screen.
        /// </summary>
        /// <param name="g">The graphics object to draw onto.</param>
        /// <param name="animationCell">The number representing which picture of animation every invader should display.</param>
        public void Draw(Graphics g, int animationCell)
        {
            g.FillRectangle(Brushes.Black, 0, 0, boundaries.Width, boundaries.Height);

            stars.Draw(g);

            foreach (Invader invader in invaders)
            {
                invader.Draw(g, animationCell);
            }

            playerShip.Draw(g);

            foreach (Shot shot in playerShots)
            {
                shot.Draw(g);
            }

            foreach (Shot shot in invaderShots)
            {
                shot.Draw(g);
            }

            DrawScoreAndWaveProgress(g);

            DrawLivesLeft(g);
        } // end method Draw
Ejemplo n.º 6
0
 //Main draw function
 public void Draw(Graphics g, int animationCell)
 {
     //Total seconds takes the absolute time difference and not only the second part of the difference
     if ((DateTime.Now - initialScreen).TotalSeconds < 5)
     {
         Point initialPosition = new Point((boundaries.Right + boundaries.Left - 2 * initialImage.Size.Width) / 2, (boundaries.Top + boundaries.Bottom - 2 * initialImage.Size.Height) / 2);
         g.DrawImage(initialImage, initialPosition.X, initialPosition.Y, initialImage.Size.Width * 2, initialImage.Size.Height * 2);
     }
     else
     {
         stars.Draw(g);
         playerShip.Draw(g);
         invaders.Draw(g, GetAnimationCell());
         playerShots.Draw(g);
         enemyShots.Draw(g);
         display.DrawScore(g, 0, 0);
         display.DrawNumberOfLives(g, LivesLeft);
     }
 }