|
-
Dec 22nd, 2007, 06:33 PM
#1
Thread Starter
Frenzied Member
[2.0] A little help with drawing images...
Ok, this is my code:
Code:
for (int i = 0; i < (currentMap.GetUpperBound(0) + 1); i++)
{
for (int k = 0; k < (currentMap.GetUpperBound(1) + 1); k++)
{
Bitmap bmp = new Bitmap(tileImageList[currentMap[i, k]]);
e.Graphics.DrawImage(bmp, new Point(k * tileHeight, (i * tileWidth) + ms.Height));
}
}
currentMap is 2D array, that I specify the values for at runtime, my problem is, if I specify 20, 20 (which is 20 tiles * 20 tiles), it generates it, but my form can only view 11 tiles wide, and 8 tiles long, which is 88 tiles, but my form is showing 400, although I can not see them, my memory usage shows that they are there...
I want to draw only the tiles visible...
The code I am currently using is:
Code:
for (int i = 0; i < (currentMap.GetUpperBound(0) + 1) - mapY; i++)
{
for (int k = 0; k < (currentMap.GetUpperBound(1) + 1) - mapX; k++)
{
Bitmap bmp = new Bitmap(tileImageList[currentMap[i, k]]);
e.Graphics.DrawImage(bmp, new Point(k * tileHeight, (i * tileWidth) + ms.Height));
}
}
mapY is increased if I click 'down' and decreased if I click 'up'
mapX is increased if I click 'right' and decreased if I click 'left'...
I am wondering how I can draw only the images I see;
I have tried starting the loop at mapY and ending it at mapY + formTilesY+1, but then if my grid isn't large enough it doesn't work...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|