示例#1
0
        public bool CalculateGravity()
        {
            /*<Summary> N9932798 Julian Shores
             * The calculate gravity function takes multiple functions' output to return a result.
             * Firstly it checks for the boolean result of the Alive() function, then reacting accordingly.
             * Secondly it gets the map and checks to see if the tank fits. If not, false is returned.
             * Falling damage is calculated, otherwise.
             * Thridly the function does a check to see if the tank is still within the bounds of the screen.
             * If not, the tank's armour is reduced to 0.
             * </Summary>
             */

            if (Alive() == false)
            {
                return(false);
            }
            current_game.GetMap();
            if (current_game.GetMap().TankFits(TX, TY))
            {
                return(false);
            }
            else
            {
                TY     += 1;
                armour -= 1;
            }

            if (TY == Battlefield.HEIGHT - Chassis.HEIGHT)
            {
                armour = 0;
            }
            return(true);
        }
示例#2
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);
                    }
                }
            }
        }