Compare commits
2 Commits
SQC-22
...
SQC-33_Ret
Author | SHA1 | Date | |
---|---|---|---|
|
c98625a610 | ||
|
80a5bf90b4 |
@@ -16,6 +16,9 @@ void World::SetSeed(uint64_t seed) {
|
|||||||
m_seed = seed;
|
m_seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Chunk* World::ChunkAt(float x, float y, float z) const {
|
Chunk* World::ChunkAt(float x, float y, float z) const {
|
||||||
int cx = (int)x / CHUNK_SIZE_X;
|
int cx = (int)x / CHUNK_SIZE_X;
|
||||||
int cz = (int)z / CHUNK_SIZE_Z;
|
int cz = (int)z / CHUNK_SIZE_Z;
|
||||||
@@ -31,6 +34,32 @@ Chunk* World::ChunkAt(float x, float y, float z) const {
|
|||||||
|
|
||||||
Chunk* World::ChunkAt(const Vector3f& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
|
Chunk* World::ChunkAt(const Vector3f& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
|
||||||
|
|
||||||
|
void World::RemoveChunk(int nbReduit)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < WORLD_SIZE_X; ++x)
|
||||||
|
for (int y = 0; y < WORLD_SIZE_Y; ++y)
|
||||||
|
{
|
||||||
|
Chunk* chk = nullptr;
|
||||||
|
if (x < nbReduit)
|
||||||
|
chk = m_chunks.Remove(x, y);
|
||||||
|
if (y < nbReduit)
|
||||||
|
chk = m_chunks.Remove(x, y);
|
||||||
|
if (y > WORLD_SIZE_Y - nbReduit)
|
||||||
|
chk = m_chunks.Remove(x, y);
|
||||||
|
if (x > WORLD_SIZE_X - nbReduit)
|
||||||
|
chk = m_chunks.Remove(x, y);
|
||||||
|
|
||||||
|
// TODO: MakeDirty() les voisins pour qu'ils se redessinent.
|
||||||
|
|
||||||
|
if (!chk)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_tbDeleted.emplace_back(chk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const {
|
BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const {
|
||||||
Chunk* c = ChunkAt(x, y, z);
|
Chunk* c = ChunkAt(x, y, z);
|
||||||
|
|
||||||
|
@@ -28,6 +28,8 @@ public:
|
|||||||
Chunk* ChunkAt(float x, float y, float z) const;
|
Chunk* ChunkAt(float x, float y, float z) const;
|
||||||
Chunk* ChunkAt(const Vector3f& pos) const;
|
Chunk* ChunkAt(const Vector3f& pos) const;
|
||||||
|
|
||||||
|
void RemoveChunk(int nbReduit);
|
||||||
|
|
||||||
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
|
|
||||||
|
@@ -275,45 +275,6 @@ void Engine::DrawMenu()
|
|||||||
ShowCursor();
|
ShowCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DrawPause()
|
|
||||||
{
|
|
||||||
static const int sTitle = 400;
|
|
||||||
static const int sButton = 225;
|
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
PauseBGTexture.Bind();
|
|
||||||
glLoadIdentity();
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 0);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(800, 0);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(800, 600);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 600);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
ShowCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::Init() {
|
void Engine::Init() {
|
||||||
|
|
||||||
|
|
||||||
@@ -429,12 +390,10 @@ void Engine::LoadResource() {
|
|||||||
|
|
||||||
LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||||
LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||||
LoadTexture(PauseBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
|
||||||
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
||||||
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
||||||
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
||||||
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
||||||
|
|
||||||
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
||||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
||||||
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
||||||
@@ -924,7 +883,11 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
int timer = GetCountdown(elapsedTime);
|
int timer = GetCountdown(elapsedTime);
|
||||||
|
for (int i = 1; i < WORLD_SIZE_X; i++)
|
||||||
|
{
|
||||||
|
if (timer <= COUNTDOWN - m_timerReductionChunk * i)
|
||||||
|
m_world.RemoveChunk(m_nbReductionChunk * i);
|
||||||
|
}
|
||||||
if (m_keyK) {
|
if (m_keyK) {
|
||||||
SystemNotification(m_messageNotification);
|
SystemNotification(m_messageNotification);
|
||||||
m_keyK = false;
|
m_keyK = false;
|
||||||
@@ -994,6 +957,8 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
|||||||
int Engine::GetCountdown(float elapsedTime) {
|
int Engine::GetCountdown(float elapsedTime) {
|
||||||
if (m_resetcountdown)
|
if (m_resetcountdown)
|
||||||
{
|
{
|
||||||
|
m_nbReductionChunk = 4;
|
||||||
|
m_timerReductionChunk = 30;
|
||||||
m_countdown = m_time + COUNTDOWN;
|
m_countdown = m_time + COUNTDOWN;
|
||||||
m_resetcountdown = false;
|
m_resetcountdown = false;
|
||||||
}
|
}
|
||||||
@@ -1122,6 +1087,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
|
|
||||||
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
DrawHud(elapsedTime, bloc);
|
DrawHud(elapsedTime, bloc);
|
||||||
@@ -1173,10 +1139,6 @@ void Engine::Render(float elapsedTime) {
|
|||||||
DrawMenu();
|
DrawMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::PAUSE)
|
|
||||||
{
|
|
||||||
DrawPause();
|
|
||||||
}
|
|
||||||
else if (m_gamestate == GameState::QUIT)
|
else if (m_gamestate == GameState::QUIT)
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
@@ -1204,14 +1166,7 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 36: // ESC - Quitter
|
case 36: // ESC - Quitter
|
||||||
if (m_gamestate == GameState::PLAY)
|
m_gamestate = GameState::MAIN_MENU;
|
||||||
{
|
|
||||||
m_gamestate = GameState::PAUSE;
|
|
||||||
}
|
|
||||||
else if (m_gamestate == GameState::PAUSE)
|
|
||||||
{
|
|
||||||
m_gamestate = GameState::PLAY;
|
|
||||||
}
|
|
||||||
//Stop();
|
//Stop();
|
||||||
break;
|
break;
|
||||||
case 57: // Space - Sauter
|
case 57: // Space - Sauter
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
virtual void DrawMenu();
|
virtual void DrawMenu();
|
||||||
virtual void DrawPause();
|
|
||||||
virtual void DrawSplachScreen();
|
virtual void DrawSplachScreen();
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
@@ -91,14 +90,13 @@ private:
|
|||||||
std::map<uint64_t, Player*> m_players;
|
std::map<uint64_t, Player*> m_players;
|
||||||
|
|
||||||
//Menu
|
//Menu
|
||||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
||||||
GameState m_gamestate = GameState::MAIN_MENU;
|
GameState m_gamestate = GameState::MAIN_MENU;
|
||||||
Texture MenuTitleTexture;
|
Texture MenuTitleTexture;
|
||||||
Texture MenuBGTexture;
|
Texture MenuBGTexture;
|
||||||
Texture MenuStartTexture;
|
Texture MenuStartTexture;
|
||||||
Texture MenuQuitTexture;
|
Texture MenuQuitTexture;
|
||||||
Texture MenuOptionsTexture;
|
Texture MenuOptionsTexture;
|
||||||
Texture PauseBGTexture;
|
|
||||||
Texture SplachScreenTexture;
|
Texture SplachScreenTexture;
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
@@ -111,6 +109,8 @@ private:
|
|||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
|
int m_nbReductionChunk = 4;
|
||||||
|
int m_timerReductionChunk = 30;
|
||||||
|
|
||||||
bool m_damage = false;
|
bool m_damage = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user