first start by creating a multidimensional array and constant
const int offset = 100;
Rectangle[,] Inventoryslots = new Rectangle[6, 4];
then you'll initialize with a double nested for loop
for (int x = 0; x < 6; x++)
{
for (int y = 0; y < 4; y++)
{
Inventoryslots[x, y] = new Rectangle((x * Width) + offset,
(y * Height) + offset, Width, Height);
}
}
then you'll do a double nested for loop to iterate through them
for (int x = 0; x < 6; x++)
{
for (int y = 0; y < 4; y++)
{
spritebatch.draw(texture, Inventoryslots[x, y], Color.White);
}
}
At least I think that's what you're asking, let me know how this works. The constant can be used to move the whole array of rectangles around (use a vector2 if you want to manipulate X and Y individually)