Example #1
0
        /*
         * Check if temporary X & Y are on the snake, the fruit, or a wall (multiplayers)
         * */
        private Boolean CheckPositions(int x, int y, FullSnake snake, Fruit fruit, List<Wall> listWalls)
        {
            Boolean ok = true;

            for (int i = 0; i < snake.Get_SnakeSize(); i++)
            {
                if (((snake.Get_Snake()[i].Get_X() == x) && (snake.Get_Snake()[i].Get_Y() == y)) || ((snake.Get_Snake()[i].Get_X() == (x + (_Side / 2 + 1))) && (snake.Get_Snake()[i].Get_Y() == y)) || ((snake.Get_Snake()[i].Get_X() == x) && (snake.Get_Snake()[i].Get_Y() == (y + (_Side / 2) + 1))) || ((snake.Get_Snake()[i].Get_X() == (x + (_Side / 2 + 1))) && (snake.Get_Snake()[i].Get_Y() == (y + (_Side / 2) + 1))))
                {
                    ok = false;
                    //Console.WriteLine("Insect is on the snake");
                }
            }

            if (((fruit.Get_X() == x) && (fruit.Get_Y() == y)) || ((fruit.Get_X() == (x + (_Side / 2 + 1))) && (fruit.Get_Y() == y)) || ((fruit.Get_X() == x) && (fruit.Get_Y() == (y + (_Side / 2) + 1))) || ((fruit.Get_X() == (x + (_Side / 2 + 1))) && (fruit.Get_Y() == (y + (_Side / 2) + 1))))
            {
                ok = false;
                //Console.WriteLine("Insect is on the fruit");
            }

            foreach (Wall element in listWalls)
            {
                if (((element.Get_X() == x) && (element.Get_Y() == y)) || ((element.Get_X() == (x + (_Side / 2 + 1))) && (element.Get_Y() == y)) || ((element.Get_X() == x) && (element.Get_Y() == (y + (_Side / 2) + 1))) || ((element.Get_X() == (x + (_Side / 2 + 1))) && (element.Get_Y() == (y + (_Side / 2) + 1))))
                {
                    ok = false;
                    //Console.WriteLine("Insect is on a wall");
                }

            }

            return ok;
        }
Example #2
0
        /////////////////////////////
        // Display of the mini fruit
        public void RenderMiniFruit(Fruit fruit, PictureBox miniGameBoardPictureBox)
        {
            if (_MiniFruit.Parent != miniGameBoardPictureBox)
                miniGameBoardPictureBox.Controls.Add(_MiniFruit);

            _MiniFruit.Location = new System.Drawing.Point(fruit.Get_X()/2, fruit.Get_Y()/2);
        }
Example #3
0
        /*
         * Check if temporary X & Y are on the snake, the fruit, the insect, or a wall
         * */
        private Boolean CheckPositions(int x, int y, FullSnake fullSnake, Fruit fruit, Insect insect, List<Wall> listWalls)
        {
            Boolean ok = true;

            for (int i = 0; i < fullSnake.Get_SnakeSize(); i++)
            {
                if ((x == fullSnake.Get_Snake()[i].Get_X()) && (y == fullSnake.Get_Snake()[i].Get_Y()))
                {
                    ok = false;
                    //Console.WriteLine("Wall appeared on the snake");
                }
            }

            if (x == fruit.Get_X() && y == fruit.Get_Y())
            {
                ok = false;
                //Console.WriteLine("Wall appeared on the fruit");
            }

            if (((insect.Get_X() == x) && (insect.Get_Y() == y)) || ((insect.Get_X() == (x + (_Side / 2 + 1))) && (insect.Get_Y() == y)) || ((insect.Get_X() == x) && (insect.Get_Y() == (y + (_Side / 2) + 1))) || ((insect.Get_X() == (x + (_Side / 2 + 1))) && (insect.Get_Y() == (y + (_Side / 2) + 1))))
            {
                ok = false;
                //Console.WriteLine("Wall appeared on the insect");
            }

            if(listWalls != null)
                for (int z = 0; z < listWalls.Count(); z++)
                {
                    if ((x == listWalls[z].Get_X()) && (z == listWalls[z].Get_Y()))
                    {
                        ok = false;
                        //Console.WriteLine("Wall appeared on a wall");
                    }
                }

            return ok;
        }
Example #4
0
        ////////////////////////
        // Display of the fruit
        public void RenderFruit(Fruit fruit, PictureBox gameBoardPictureBox)
        {
            if (_Fruit.Parent != gameBoardPictureBox)
                gameBoardPictureBox.Controls.Add(_Fruit);

            _Fruit.Location = new System.Drawing.Point(fruit.Get_X(), fruit.Get_Y());
        }