Hi Everyone, I asked this in another thread, but decided it may be better asked here (dont worry I removed other post)
I'm currently working on a game "Counter Sheep", screen shots on my website (will help explain next bit). The Land is "Rendered" using a heightmap and BG image! I'm now working on getting the items / players etc to clip behind objects etc.
I render my land with only a rotation in 1 axis, i.e the x values do not move, its just sloped forward towards the player as it's slightly easier to implement.
From what I understand, and have read, I can implement a Z_buffer in the following way :
When I render a raster (left to right), I do it as (x,z - y) (ish), I store the current z value into the z-buffer for all points drawn, i.e I draw a line from the top point or x,z-y to x,z, to get rid of the black banding in the final image.
this code sort of gives you the idea:
so for any given point I should place the current Z-value into the z-buffer for pixels x,z-y to x,z (top of the hill to ground.
correct?
so later when I go to draw a pixel at x,z-y I can compare the current z value with the one in the z-buffer at x,z-y
correct?
and if the z-buffer is bigger, dont draw the pixel?
comments?
I'm currently working on a game "Counter Sheep", screen shots on my website (will help explain next bit). The Land is "Rendered" using a heightmap and BG image! I'm now working on getting the items / players etc to clip behind objects etc.
I render my land with only a rotation in 1 axis, i.e the x values do not move, its just sloped forward towards the player as it's slightly easier to implement.
From what I understand, and have read, I can implement a Z_buffer in the following way :
When I render a raster (left to right), I do it as (x,z - y) (ish), I store the current z value into the z-buffer for all points drawn, i.e I draw a line from the top point or x,z-y to x,z, to get rid of the black banding in the final image.
this code sort of gives you the idea:
- Code:
for (x = 0; x < lvl_x; x++)
{
for (y = 0; y < lvl_z; y++)
{
level[x][y].texture = bg_img_p[x + (y * lvl_x)];
//draw master map
for (iy = 0; iy <= level[x][y].height; iy++)
play_scr_p[x + (50 + y - iy) * lvl_x] = level[x][y].texture;
}
}
so for any given point I should place the current Z-value into the z-buffer for pixels x,z-y to x,z (top of the hill to ground.
correct?
so later when I go to draw a pixel at x,z-y I can compare the current z value with the one in the z-buffer at x,z-y
correct?
and if the z-buffer is bigger, dont draw the pixel?
comments?