#ifndef BinaryTree_h
#define BinaryTree_h
#include "Chunks.h"
class node{
public:
loc key;// main location of the node
node *left;//branch of the node
node *right;// branch or leaf fo the node
chunks world;//the actual chunk of the world for this node
};
class tree{
public:
node *search(loc key, node *leaf);//contains the search algorithm
void save(loc key, node *leaf);//contains the save algorithm
void destroy(loc key, node *leaf);//destorys a specific node
node *branch;
};
#endif
#include <stdlib.h>
#ifndef Chunks_h
#define Chunks_h
#include "locationStat.h"
class block{
public:
int id;//identification number of the block which is used to determin block stats
};
class area{
public:
loc *ch1x1;
loc *ch1x2;
loc *ch1x3;
loc *ch1x4;
loc *ch2x1;
loc *ch2x2;
loc *ch2x3;
loc *ch2x4;
loc *ch3x1;
loc *ch3x2;
loc *ch3x3;
loc *ch3x4;
loc *ch4x1;
loc *ch4x2;
loc *ch4x3;
loc *ch4x4;
};
class chunks{
public:
block *chunk[1][1];
area surroundingChunks; //the area around the chunk 4x4
void searchArea(); //used to find the immediate area around the chunk.
bool create; //determins if the chunk is to be generated or just left as bool
void start(); //checks the state of create, runs chunk area, and generates terrain from a class
};
void chunks::start(){
if(create == true){
chunk[0][0] = new block[10], new block[10];
searchArea();
}
if(create != true){
searchArea();
}
}
void genTerrain(chunks chunk){
for(int a = 0; a < 10; a++)
for(int b = 0; b < 10; b++)
chunk.chunk[a][b]->id = rand() % 4;
}
#endif
locationStats.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#ifndef locationStat_h
#define locationStat_h
class loc{
public:
int corner;//contains which of the 4 corners this node occupies
int mBranch;//main branch of the node
int sBranch;//a single branch on a specific area of the main branch
bool leaf;//a part of the sub-branch at a specific point
};
#endif
Now there are a few things in the code that are not coded yet just so you know.
#include <iostream>
#include "BinaryTree.cpp"
usingnamespace std;
int main(int argc, int argv[])
{
Change it to this like in chunks.cpp:
1 2 3 4 5 6 7 8 9
#include <iostream>
#include "Chunks.h"
usingnamespace std;
int main(int argc, int argv[])
{
2 more things...
1) Some compilers complain if you have system includes inside of the Header Guard.
2) You dont need to actually define the Header Guard as some value, just defining it (asserting its presence) is good enough.
Change this in Chunks.h:
Ok i updated the code again here and in the program and i'm still getting the error...idk what could be the problem. This is really starting to irritate me.
Yeah, it is legal. And in any logical argument there should be no problem doing so.
I think it is only a compiler warning, I just recall coming in to the habit of putting them before the guards to avoid one (I am willing to bet it is one of the MS compilers that generates it.) I really do hate compiler warnings, and I regularly use 5 different C++ compilers (VS6 - yeah, VS2008, VS2010, VS2012, and GNU C++) at work and counting personal projects.
I've never come across any warning like that, and I've used each of the compilers in that list. It just doesn't make sense for any compiler to throw a warning over something like that. It's merely an application of conditional compilation.