Esempio n. 1
0
        private void checkDeath()
        {
            bool stillAlive = true;

            for (int i = 1; i < currentSnake.Elements.Count; i++)
            {
                if (currentSnake.Elements[0].PosX == currentSnake.Elements[i].PosX && currentSnake.Elements[0].PosY == currentSnake.Elements[i].PosY)
                {
                    stillAlive = false;
                }
            }

            if (currentSnake.Elements[0].PosX <= 0 || currentSnake.Elements[0].PosY <= 0 || (currentSnake.Elements[0].PosY + Globals.Width + 1) >= this.Height || (currentSnake.Elements[0].PosX + Globals.Width + 1) >= this.Width)
            {
                stillAlive = false;
            }


            if (!stillAlive)
            {
                alive = false;
                if (aiMode)
                {
                    Player.DownVoteLast();
                    WriteSituations();
                }
                timer1.Stop();
                writeScoreList();
                var      tmp = Player.Log;
                Graphics g   = this.CreateGraphics();
                g.Clear(Color.Black);

                g.FillEllipse(new SolidBrush(Color.Red), new Rectangle(currendFood.posX, currendFood.posY, currendFood.width, currendFood.width));

                foreach (SnakeDot dot in currentSnake.Elements)
                {
                    g.FillEllipse(new SolidBrush(Color.Red), new Rectangle(dot.PosX, dot.PosY, dot.Width, dot.Width));
                }

                restart();
            }
        }