Merge branch 'master' into SQC-15_paquets
This commit is contained in:
commit
71852738c1
@ -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,24 @@ 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)
|
||||||
|
{
|
||||||
|
if (x < nbReduit)
|
||||||
|
m_chunks.Remove(x,y);
|
||||||
|
if (y < nbReduit)
|
||||||
|
m_chunks.Remove(x, y);
|
||||||
|
if (y > WORLD_SIZE_Y - nbReduit)
|
||||||
|
m_chunks.Remove(x, y);
|
||||||
|
if (x > WORLD_SIZE_X - nbReduit)
|
||||||
|
m_chunks.Remove(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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,6 +275,45 @@ 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() {
|
||||||
|
|
||||||
|
|
||||||
@ -397,10 +436,12 @@ 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");
|
||||||
@ -890,7 +931,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;
|
||||||
@ -960,6 +1005,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;
|
||||||
}
|
}
|
||||||
@ -1088,6 +1135,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);
|
||||||
@ -1177,6 +1225,10 @@ 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,7 +1256,14 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 36: // ESC - Quitter
|
case 36: // ESC - Quitter
|
||||||
m_gamestate = GameState::MAIN_MENU;
|
if (m_gamestate == GameState::PLAY)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
@ -28,6 +28,7 @@ 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();
|
||||||
@ -94,13 +95,14 @@ private:
|
|||||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||||
|
|
||||||
//Menu
|
//Menu
|
||||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
||||||
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;
|
||||||
@ -113,6 +115,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;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user