Ejemplo n.º 1
0
        private void DrawBackground()
        {
            Graphics graphics   = backgroundGraphics.Graphics;
            Image    background = backgroundImage;

            graphics.DrawImage(backgroundImage, new Rectangle(0, 0, displayPanel.Width, displayPanel.Height));

            Battlefield battlefield = currentGame.GetMap();
            Brush       brush       = new SolidBrush(landscapeColour);

            for (int y = 0; y < Battlefield.HEIGHT; y++)
            {
                for (int x = 0; x < Battlefield.WIDTH; x++)
                {
                    if (battlefield.IsTileAt(x, y))
                    {
                        int drawX1 = displayPanel.Width * x / levelWidth;
                        int drawY1 = displayPanel.Height * y / levelHeight;
                        int drawX2 = displayPanel.Width * (x + 1) / levelWidth;
                        int drawY2 = displayPanel.Height * (y + 1) / levelHeight;
                        graphics.FillRectangle(brush, drawX1, drawY1, drawX2 - drawX1, drawY2 - drawY1);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Calling this method calls the GameplayTank to fall down one tile, if possible.
 /// </summary>
 /// <returns>Returns true if the tank moved, false otherwise</returns>
 public bool ProcessGravity()
 {
     if (!TankExists())
     {
         return(false);
     }
     else
     {
         //If there is any terrain within the tank area, this method returns true. Otherwise it returns false
         if (game.GetMap().TankFits(tankX, tankY + 1))
         {
             return(false);
         }
         else
         {
             tankY++;
             durability--;
             if (tankY == Battlefield.HEIGHT - Chassis.HEIGHT)
             {
                 durability = 0;
             }
             return(true);
         }
     }
 }