Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
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;
            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
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
Your Filters
0 Shai Vashdi 319
1 OriginalGriff 280
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 171
4 Abhinav S 168
0 Sergey Alexandrovich Kryukov 8,979
1 OriginalGriff 5,280
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263

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