The -1 is just so I can see where the level ends. Also, I posted the wrong code snippet and firefox ate my reply. I'm just gonna upload the whole damn folder. I'm not sure why I'm so worried about this. Also, to answer Normany's question: What do you mean, allocate memory? Here is my main function:
int main(int argc, char** argv)
{
int resolutionSizeX = 1080;
int resolutionSizeY = 960;
DisplayerOutputer display;
PlayerViewSettings player;
IrrlichtDevice * device =
createDevice(EDT_OPENGL, dimension2d<u32>(resolutionSizeX, resolutionSizeY), 16,
false, false, false, 0);
SAppContext context;
context.playerView = &player;
context.device = device;
loadPngs(context);
for (int i = 0; i < NUMBER_OF_PLANETS; i++)
{
context.planetMaps[i] = new PlanetMaps ;
for (int i2 = 0; i2 < planetZdimension; i2++)
{
context.planetMaps[i]->fillEmpty(i2);
}
printf("\nPLanet #"); printf("%p", context.planetMaps[i]);
}
context.planetMaps[0]->fillDirt(6);
context.planetMaps[0]->fillDirt(0);
SetupGraphics( context );
MyEventReceiver receiver(context);
device->setEventReceiver(&receiver);
IVideoDriver* driver = device->getVideoDriver();
while(device->run())
{
driver->beginScene(true, true, SColor(0,200,200,200));
display.drawGraphics(context);
driver->endScene();
}
device->drop();
return EXIT_SUCCESS;
So far as allocating memory goes, that's all I know. I'll post the PlanetMaps class next:
const int planetXdimension = 96;
const int planetYdimension = 64;
const int planetZdimension = 16;
enum TerrainTypes {EMPTY = 'n',
DIRT,
ROCK,
ORE};
enum TerrainAspect {LEVEL, SLOPE_NORTH, SLOPE_SOUTH, SLOPE_EAST, SLOPE_WEST,
SLOPE_NW, SLOPE_NE, SLOPE_SW, SLOPE_SE};
struct PlanetMaps
{
TerrainTypes terrainMap [planetZdimension][planetYdimension][planetXdimension];
int planetX;
int planetY;
void fillDirt(int);
void fillEmpty(int);
void drawTestLine(int);
void drawTestArrow();
};
void PlanetMaps::drawTestArrow()
{
drawTestLine(5);
for (int i = 1; i < 10; i++)
{
terrainMap[1][0][i] = DIRT;
}
}
void PlanetMaps::fillDirt(int z)
{
for (int y = 0; y < planetYdimension - 1 ; y++)
{
for (int x = 0; x < planetXdimension - 1 ; x++)
{
terrainMap[z][y][x] = DIRT;
}
}
}
void PlanetMaps::fillEmpty(int z)
{
{
for (int y = 0; y < planetYdimension ; y++)
{
for (int x = 0; x < planetXdimension ; x++)
{
terrainMap[z][y][x] = EMPTY;
}
}
}
void PlanetMaps::drawTestLine(int line)
{
for (int i = 0; i < 16; i++)
{
terrainMap[1][i][line] = DIRT;
}
}
Also, PlanetMaps.planetX and PlanetMaps.planetY are irrlevant. Having some trouble with rapidshare so you cant get the whole source. I'll post a pic later if my error wasnt obvious.
Oh, and the context struct:
struct SAppContext
{
IrrlichtDevice *device;
IGUIFont* font;
PlanetMaps *planetMaps[NUMBER_OF_PLANETS];
PlayerViewSettings *playerView;
video::ITexture *emptyBlock;
video::ITexture *dirtBlock;
video::ITexture *testBlock;
};