Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (32 sloc) 1.66 KB
//Draw the gameview
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
int GVOriginX, GVOriginY;
GVOriginX = fov.Player.X - iViewWidth / 2;
GVOriginY = fov.Player.Y - iViewHeight / 2;
if (GVOriginX < 0)
GVOriginX = 0;
else if (GVOriginX + iViewWidth > fov.map.GetLength(0))
GVOriginX -= (GVOriginX + iViewWidth - fov.map.GetLength(0));
if (GVOriginY < 0)
GVOriginY = 0;
else if (GVOriginY + iViewHeight > fov.map.GetLength(1))
GVOriginY -= (GVOriginY + iViewHeight - fov.map.GetLength(1));
for (int x = 0 ; x < iViewWidth; x++)
for (int y = 0; y < iViewHeight; y++)
if (fov.map[x + GVOriginX, y + GVOriginY] == 0)
{
//draw the bFloor in the specified point
e.Graphics.DrawImage(bFloor, new Point(x * iTileWidth,
y * iTileHeight));
//FOV Algorithm:
//if the map cell being drawn is not contained in
//the VisualPoints list generated by the FOV algorithm, draw the fog over it
if (!fov.VisiblePoints.Contains(new Point(x + GVOriginX, y + GVOriginY)))
e.Graphics.DrawImage(bFog, new Point(x * iTileWidth
, y * iTileHeight));
}
//draw the bPlayer bitmap in the specified point
e.Graphics.DrawImage(bPlayer, new Point((fov.Player.X - GVOriginX) * iTileWidth
, (fov.Player.Y - GVOriginY) * iTileHeight ));
}