HALLELUJAH!!
This commit is contained in:
@@ -45,26 +45,90 @@ void Engine::Init()
|
||||
m_skybox.Init(0.00013f);
|
||||
|
||||
// Objet de musique!
|
||||
//m_audio.ToggleMusicState();
|
||||
m_audio.ToggleMusicState();
|
||||
|
||||
for (int x = 0; x < CHUNK_SIZE_X; ++x)
|
||||
for (int z = 0; z < CHUNK_SIZE_Z; ++z)
|
||||
for (int y = 0; y < 32; ++y)
|
||||
m_copychunk.SetBlock(x, y, z, BTYPE_GRASS);
|
||||
|
||||
m_copychunk.SetBlock(5, 32, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(5, 33, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(5, 34, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(6, 34, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(7, 34, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(7, 33, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(7, 32, 15, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(8, 32, 3, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(8, 33, 4, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(8, 34, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(8, 35, 6, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(11, 32, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(11, 33, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(11, 34, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(11, 35, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(12, 32, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(12, 33, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(12, 34, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(12, 35, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(13, 32, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(13, 33, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(13, 34, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(13, 35, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(14, 32, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(14, 33, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(14, 34, 5, BTYPE_GRASS);
|
||||
m_copychunk.SetBlock(14, 35, 5, BTYPE_GRASS);
|
||||
|
||||
for (int chx = 0; chx < VIEW_DISTANCE; ++chx)
|
||||
for (int chy = 0; chy < VIEW_DISTANCE; ++chy)
|
||||
m_world.GetChunks().Set(chx, chy, &m_copychunk);
|
||||
|
||||
// Init Chunks
|
||||
for (int chx = 0; chx < VIEW_DISTANCE; ++chx)
|
||||
for (int chy = 0; chy < VIEW_DISTANCE; ++chy)
|
||||
m_chunks.Set(chx, chy, new Chunk(chx, chy));
|
||||
//for (int chx = 0; chx < VIEW_DISTANCE; ++chx)
|
||||
// for (int chy = 0; chy < VIEW_DISTANCE; ++chy)
|
||||
// m_world.GetChunks().Set(chx, chy, new Chunk(chx, chy));
|
||||
|
||||
// G<>n<EFBFBD>ration Chunks.
|
||||
for (int chx = 0; chx < VIEW_DISTANCE; ++chx)
|
||||
for (int chy = 0; chy < VIEW_DISTANCE; ++chy) {
|
||||
// // G<>n<EFBFBD>ration Chunks.
|
||||
// for (int chx = 0; chx < VIEW_DISTANCE; ++chx)
|
||||
// for (int chy = 0; chy < VIEW_DISTANCE; ++chy) {
|
||||
|
||||
for (int x = 0; x < CHUNK_SIZE_X; ++x)
|
||||
for (int z = 0; z < CHUNK_SIZE_Z; ++z)
|
||||
for (int y = 0; y < 32; ++y)
|
||||
m_chunks.Get(chx, chy)->SetBlock(x, y, z, BTYPE_DIRT);
|
||||
// for (int x = 0; x < CHUNK_SIZE_X; ++x)
|
||||
// for (int z = 0; z < CHUNK_SIZE_Z; ++z)
|
||||
// for (int y = 0; y < 32; ++y)
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(x, y, z, BTYPE_GRASS);
|
||||
|
||||
m_chunks.Get(chx, chy)->SetBlock(8, chx + 32, 8, BTYPE_DIRT);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(5, 32, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(5, 33, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(5, 34, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(6, 34, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(7, 34, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(7, 33, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(7, 32, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(8, 32, 3, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(8, 33, 4, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(8, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(8, 35, 6, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(11, 32, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(11, 33, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(11, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(11, 35, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(12, 32, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(12, 33, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(12, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(12, 35, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(13, 32, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(13, 33, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(13, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(13, 35, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 32, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 33, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 35, 5, BTYPE_GRASS);
|
||||
|
||||
}
|
||||
// //m_world.GetChunks().Get(chx, chy)->SetBlock(8, chx + 32, 8, BTYPE_DIRT);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// Gestion de souris.
|
||||
@@ -111,7 +175,7 @@ void Engine::LoadResource() {
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::UnloadResource(){}
|
||||
void Engine::UnloadResource() {}
|
||||
|
||||
void Engine::DrawHud(float elapsedTime) {
|
||||
// Setter le blend function , tout ce qui sera noir sera transparent
|
||||
@@ -141,13 +205,16 @@ void Engine::DrawHud(float elapsedTime) {
|
||||
ss.str("");
|
||||
ss << " Position : " << m_player.GetPosition();
|
||||
PrintText(10, 30, ss.str());
|
||||
ss.str("");
|
||||
ss << " Delta : " << m_player.GetPOV();
|
||||
PrintText(10, 40, ss.str());
|
||||
// Affichage du crosshair
|
||||
m_textureCrosshair.Bind();
|
||||
static const int crossSize = 32;
|
||||
glLoadIdentity();
|
||||
glTranslated(Width() / 2 - crossSize / 2, Height() / 2 - crossSize / 2, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(crossSize, 0);
|
||||
@@ -190,6 +257,7 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
||||
|
||||
void Engine::Render(float elapsedTime) {
|
||||
static float gameTime = elapsedTime;
|
||||
if (elapsedTime > 0.1f) return;
|
||||
|
||||
gameTime += elapsedTime;
|
||||
|
||||
@@ -202,7 +270,7 @@ void Engine::Render(float elapsedTime) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
m_player.Move(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, m_keylshift, elapsedTime);
|
||||
m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, m_keylshift, elapsedTime), m_world, elapsedTime);
|
||||
m_audio.Update3DAudio(m_player.GetPosition(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
|
||||
// son vecteur de v<>locit<69> (pour l'effet Doppler)
|
||||
m_player.ApplyTransformation(all);
|
||||
@@ -211,8 +279,6 @@ void Engine::Render(float elapsedTime) {
|
||||
glDisable(GL_LIGHT0);
|
||||
m_skybox.Render(skybox);
|
||||
|
||||
|
||||
|
||||
// Chunks
|
||||
all.Use();
|
||||
glEnable(GL_LIGHT0);
|
||||
@@ -220,14 +286,14 @@ void Engine::Render(float elapsedTime) {
|
||||
m_textureAtlas.Bind();
|
||||
for (int chx = 0; chx < VIEW_DISTANCE; chx++)
|
||||
for (int chy = 0; chy < VIEW_DISTANCE; chy++) {
|
||||
all.ApplyTranslation(chx * CHUNK_SIZE_X - (VIEW_DISTANCE * CHUNK_SIZE_X / 2), -(CHUNK_SIZE_Y / 2), chy * CHUNK_SIZE_Z - (VIEW_DISTANCE * CHUNK_SIZE_Z / 2));
|
||||
all.ApplyTranslation(chx * CHUNK_SIZE_X, 0, chy * CHUNK_SIZE_Z);
|
||||
all.Use();
|
||||
if (m_chunks.Get(chx, chy)->IsDirty())
|
||||
m_chunks.Get(chx, chy)->Update(m_blockinfo);
|
||||
m_chunks.Get(chx, chy)->Render();
|
||||
all.ApplyTranslation(-(chx * CHUNK_SIZE_X - (VIEW_DISTANCE * CHUNK_SIZE_X / 2)), CHUNK_SIZE_Y / 2, -(chy * CHUNK_SIZE_Z - (VIEW_DISTANCE * CHUNK_SIZE_Z / 2)));
|
||||
if (m_world.GetChunks().Get(chx, chy)->IsDirty())
|
||||
m_world.GetChunks().Get(chx, chy)->Update(m_blockinfo);
|
||||
m_world.GetChunks().Get(chx, chy)->Render();
|
||||
all.ApplyTranslation(-chx * CHUNK_SIZE_X, 0, -chy * CHUNK_SIZE_Z);
|
||||
}
|
||||
|
||||
|
||||
m_shader01.Disable();
|
||||
|
||||
if (m_wireframe)
|
||||
|
Reference in New Issue
Block a user