////////////////////////////// // Display of the mini insect public void RenderMiniInsect(Insect insect, PictureBox miniGameBoardPictureBox) { if (_MiniInsect.Parent != miniGameBoardPictureBox) miniGameBoardPictureBox.Controls.Add(_MiniInsect); _MiniInsect.Location = new System.Drawing.Point(insect.Get_X()/2, insect.Get_Y()/2); }
/* * 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; }
//////////////////////// // Display of the insect public void RenderInsect(Insect insect, PictureBox gameBoardPictureBox) { if (_Insect.Parent != gameBoardPictureBox) gameBoardPictureBox.Controls.Add(_Insect); _Insect.Location = new System.Drawing.Point(insect.Get_X(), insect.Get_Y()); }