13,508,228 members
See more:
Dear CodeProject,

I have been working on my game for the past couple of days, and for some odd reason the following code won't work:

```// -- Write the world bytes.
for (int i = ChunkSize; i > 0; i--)
{
for (int j = ChunkSize; j > 0; j--)
{
// -- Block.
char Block;
if (ChunkY > 0 || (ChunkY == 0 && j > World.ChunkSize / 2))
{
Block = (char)BlockID.BLOCK_GRASS;
}
else
Block = (char)BlockID.BLOCK_AIR;

_ReturnString = _ReturnString + Block.ToString();
}
}```

Well, in fact, it works. But the only thing that doesn't work is this part:

`(ChunkY == 0 && j > World.ChunkSize / 2))`

Also keep in mind that I am writing the world from the end to the beginning, the reason why is because I read it out afterwards and it's backwards if I don't also write it backwards.

If you do not understand my problem: Basically, I am creating a flatgrass, but if the chunkY coordinate is 0 it should fill the grass all the way to the middle instead of the whole chunk. And it's basically only doing it for the whole chunk thing.
Posted 23-Dec-12 1:48am
Updated 23-Dec-12 1:59am
v2
Shahin Khorshidnia 23-Dec-12 8:44am

So what is your C# problem? You may correct the algorithm firstly.
Yvar Birx 23-Dec-12 9:21am

My problem is as I said this: "(ChunkY == 0 && j > World.ChunkSize / 2))". There is no algorithm as this is flat grass.
Daniele Rota Nodari 27-Dec-12 7:15am

You are looping j from ChunkSize to 1 and comparing it with World.ChunkSize / 2.
Are ChunkSize and World.ChunkSize in some way related?
What are current values for ChunkSize, ChunkY, World.ChunkSize?

Top Experts
Last 24hrsThis month
 OriginalGriff 275 Maciej Los 125 Richard MacCutchan 115 Jochen Arndt 100 W∴ Balboos 85
 OriginalGriff 4,606 Jochen Arndt 2,463 ppolymorphe 2,122 Wendelius 2,033 Maciej Los 1,824