Some improvements made to world generator.
This commit is contained in:
parent
ab791decbd
commit
997add55c5
@ -164,10 +164,14 @@ Cube* Chunk::getCube(int x, int y, int z) {
|
||||
}
|
||||
|
||||
float getTexOffsetU(int type) {
|
||||
return 0;
|
||||
return (type - 1) * 0.125;
|
||||
}
|
||||
|
||||
float getTexOffsetV(int type) {
|
||||
if(type > 8) {
|
||||
type <<= 3; // Here 8 is the image width in texs
|
||||
return 1 - type * 0.125;
|
||||
}
|
||||
return 0.875;
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,7 @@ void Game::loadTextures() {
|
||||
m_textures["cobblestone"] = loadTexture("textures/cobblestone.bmp");
|
||||
m_textures["stone"] = loadTexture("textures/stone.bmp");
|
||||
m_textures["bedrock"] = loadTexture("textures/bedrock.bmp");
|
||||
m_textures["textures"] = loadTexture("textures/textures.bmp");
|
||||
}
|
||||
|
||||
void Game::lockMouse() {
|
||||
|
@ -51,11 +51,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// Game execution
|
||||
Game *game = new Game();
|
||||
game->exec();
|
||||
|
||||
// Delete all objects
|
||||
delete game;
|
||||
Game game = Game();
|
||||
game.exec();
|
||||
|
||||
// Stop SDL
|
||||
SDL_Quit();
|
||||
|
@ -77,7 +77,10 @@ Map::Map(u16 width, u16 depth, u16 height, Textures textures) {
|
||||
else if (heightValue >= m_height) heightValue = m_height - 1;
|
||||
|
||||
for(int zz = 0 ; zz < heightValue ; zz++) {
|
||||
m_map[_MAP_POS(xC + (xx << 3), yC + (yy << 3), zz)] = 1;
|
||||
int dirtHeight = (1.0 - rand()%10 / 100 - 0.20) * heightValue;
|
||||
if(zz < dirtHeight) m_map[_MAP_POS(xC + (xx << 3), yC + (yy << 3), zz)] = 1;
|
||||
else if(zz > dirtHeight && zz < dirtHeight + 2) m_map[_MAP_POS(xC + (xx << 3), yC + (yy << 3), zz)] = rand()%2 + 1;
|
||||
else m_map[_MAP_POS(xC + (xx << 3), yC + (yy << 3), zz)] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,8 +146,6 @@ Map::~Map() {
|
||||
}
|
||||
|
||||
delete[] m_chunks;
|
||||
|
||||
delete selectedCube;
|
||||
}
|
||||
|
||||
void Map::draw() {
|
||||
@ -157,7 +158,7 @@ void Map::draw() {
|
||||
glEnd();
|
||||
glColor3ub(255, 255, 255);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_textures["stone"]);
|
||||
glBindTexture(GL_TEXTURE_2D, m_textures["textures"]);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Loading…
x
Reference in New Issue
Block a user