Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# XNA3.0
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;
 
        // -- Add Return.
        _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
Yvar Birx2.4K
Edited 23-Dec-12 1:59am
v2
Comments
Shahin Khorshidnia at 23-Dec-12 8:44am
   
So what is your C# problem? You may correct the algorithm firstly.
Yvar Birx at 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 at 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?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,240
3 George Jonsson 3,584
4 Gihan Liyanage 2,625


Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100