Hey guys.
Not sure if im on the correct forum but anywho...im using c# with XNA to create a 2D board game.
Ive used a tile engine to draw the images of each tile(to make up the entire board) to the screen.
Now im trying to create a 2D array(below) to depicate the actual board
Do I have to initialize the array and go through each tile on the board(with all the 0's)
int[,] myArray = new int[10,5];
int[,] myArray = new int[,] {{0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, (0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, (0,,0,0,0,0},{0,0,0,0,0}, {0,0,0,0,0}};
PrintArray(myArray);
public class ArrayClass
{
static void PrintArray(int[,] w)
{
// Display the array elements:
for (int i=0; i < 10; i++)
for (int j=0; j < 5; j++)
//is the below line correct?
Console.WriteLine("Element({0},{1})={2}", i, j, w[i,j]);
}
public static void Main()
{
// Pass the array as a parameter:
PrintArray(new int[,] {{0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, (0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, (0,,0,0,0,0},{0,0,0,0,0}, {0,0,0,0,0}};
}
}
P.S how do i post code properly on this site?
Thanks in advance for any replies.
John