I would like to iterate through an array that covers every pixel on my screen. i.e:
for (int y = 598; y > 0; y--)
{
for (int x = 798; x > 0; x--)
{
if (grains[x][y])
{
spriteBatch.Draw(Grain, new Vector2(x,y), Color.White);
}
}
}
…my texture is a 1×1 pixel image that is drawn to the screen when the array value is true. It runs decent — but there is definitely lag the more screen I cover. Is there a better way to accomplish what I am trying to achieve?
Instead of using X x Y individual sprites, create a single image, and set the pixels appropriately. Then just render the entire image as a texture on a single sprite.
The jagged array is most likely not the problem – rather the nearly half-million sprites.