I'm trying to make the game 2048 in C#, but I have a problem when I move the tiles.
Here is where I keep the tiles:
picture = new PictureBox[4, 4] {
{pic1,pic2,pic3,pic4},
{pic5,pic6,pic7,pic8},
{pic9,pic10,pic11,pic12},
{pic13,pic14,pic15,pic16} };
And when I press 'W' I move it up :
public void Up()
{
for (int i = 1; i < picture.GetLength(0); i++)
for (int j = 0; j < picture.GetLength(1); j++)
if(picture[i,j].Image!=null && picture[i-1,j].Image==null)
{
picture[i - 1, j].Image = picture[i, j].Image;
picture[i, j].Image = null;
Up();
}
}
but that code only interchanges images from picturebox not the picturebox itself. How can I interchange the picturebox with image and all its property ?