Hi, so I'm working on a 2D isometric style game with block terrain generation. So far I have set up code for the terrain generation with both DirectX 11's Direct2D in Windows and SFML in Linux. I'd like to make the game cross platform and so far that aspect is working well.
I have a few questions maybe someone can fill me in on, but first I should show you my code so far (at least the terrain generation part) and the output I'm getting. Like so:
for (int x = 0; x < MapWidth; x++)
{
for (int y = 0; y < MapHeight; y++)
{
// Get the depth value.
float nOffX = (float)x / (float)(MapWidth - 1);
float nOffY = (float)y / (float)(MapHeight - 1);
float nX = 128.0f + nOffX * (256.0f - 128.0f);
float nY = 128.0f + nOffY * (256.0f - 128.0f);
int MaxDepth = lround(perlinNoise.GetValue(nX,nY, 0) * 10);
MaxDepth = noise::ClampValue(MaxDepth, 0, MapDepth);
for (int z = -1; z < MaxDepth - layer; z++)
{
// Adjust for Isometric Coordinates.
int isoX = (((x - (z * 2)) + y) * TileWidth / 4);
int isoY = ((y - x) * TileHeight / 2);
isoX += (600 / 4) - (TileWidth / 2);
isoY += (800 / 2) - (TileHeight / 2);
terrainImage.copy(rawImage, isoY, isoX,sf::IntRect(0,0,32,32), true);
}
}
}
So this is the code I'm using to create the terrain in Isometric adjusted 2D space. This is the SFML version from linux for those not familiar. The code in DirectX is essentially the same except I use the Draw methods there for creating the sprite texture. I'm creating it as one texture and then drawing it to the screen as I figured that I should probably use one draw call for the terrain or I would have major performance issues when rendering huge chunks of blocks. The output of this code looks like this:
The style of game I'm imagining is something like dwarf fortress with graphics mixed with elements from some other genres of games such as rpgs and rts. So in other words you will be in control of a "Kingdom" style of game as the player building and defending your kingdom of isometric 2D blocks from invaders, monsters, other kingdoms, ect...
I realize this style of game has been done before in a couple of instances, but I'd like to make my own as I love this style of game alot. And I think I could make a really good instance of the god game or kingdom builder genre if you will.
This leads me to a couple of Questions about creating a game like this:
Question 1: How do I go about getting better output from the noise algorithm and terrain generation algorithm I'm using? I need the terrain to be a bit more natural looking with hills, and valleys, and possibly even mountains when I go to a much large grid say something like 1024 by 1024 tiles.
Question 2: Is there a better way to go about generating the terrain? And will the way I've chosen lead to any issues when I start doing pathfinding stuff for the characters?
Question 3: How do I go about adding and removing blocks?
Question 4: How should I go about drawing the blocks in real time in a "layered" like fashion? I need the player to be able to run through the layers of blocks for adding and removing blocks in a mining style fashion.
That's all the questions I have for now, and probably the most essential ones for making this style of game. Any help or thoughts on my project/game would be greatly appreciated!
Edit: Also sorry if this is in the wrong forum... I'm kind of new here and not used to posting in this forum. If it is could a moderator please move it to the correct forum where I am more likely to get help with this topic? I wasn't sure where to put this since it's cross platform and cross API development and kind of generalized in questions... thanks again.