Compare commits
	
		
			1 Commits
		
	
	
		
			affichage_
			...
			MeshOptimi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 75ca13ccfc | 
| @@ -110,28 +110,49 @@ void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) { | ||||
|  | ||||
| BlockType Chunk::GetBlock(int x, int y, int z) { return m_blocks.Get(x, y, z); } | ||||
|  | ||||
| void Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) { | ||||
| NEIGHBOR_CHUNK_POSITION Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) { | ||||
|     unsigned int cx, cy; | ||||
|  | ||||
|     world->GetScope(cx, cy); | ||||
|  | ||||
|     if (x == 0 && m_posX - cx >= 0 && | ||||
|         world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)) | ||||
|     if (x == 0 && m_posX - cx >= 0 && world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)) { | ||||
|         world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty(); | ||||
|     else if (x == CHUNK_SIZE_X - 1 && m_posX - cx < WORLD_SIZE_X &&  | ||||
|         world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)) | ||||
|         return X_MINUS; | ||||
|     } | ||||
|     else if (x == CHUNK_SIZE_X - 1 && m_posX - cx < WORLD_SIZE_X && world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)) { | ||||
|         world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty(); | ||||
|         return X_PLUS; | ||||
|     } | ||||
|  | ||||
|     if (z == 0 && m_posY - cy >= 0 &&  | ||||
|         world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z)) | ||||
|     if (z == 0 && m_posY - cy >= 0 && world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z)) { | ||||
|         world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z)->MakeDirty(); | ||||
|     else if (z == CHUNK_SIZE_X - 1 && m_posY - cy < WORLD_SIZE_Y && | ||||
|         world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)) | ||||
|         return Z_MINUS; | ||||
|     } | ||||
|     else if (z == CHUNK_SIZE_X - 1 && m_posY - cy < WORLD_SIZE_Y && world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)) { | ||||
|         world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)->MakeDirty(); | ||||
|         return Z_PLUS; | ||||
|     } | ||||
|  | ||||
|     return NONE; | ||||
| } | ||||
|  | ||||
| void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; } | ||||
|  | ||||
| void Chunk::AddAllVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int cx, int cy, int x, int y, int z, float u, float v, float s, World* world) { | ||||
|     if (world->BlockAt(cx + 1, y, cy) == BTYPE_AIR) { | ||||
|         AddXPlusVertices(vd, count, bt, x, y, z, u, v, s); | ||||
|     } | ||||
|     if (world->BlockAt(cx - 1, y, cy) == BTYPE_AIR) { | ||||
|         AddXMinusVertices(vd, count, bt, x, y, z, u, v, s); | ||||
|     } | ||||
|     if (world->BlockAt(cx, y, cy + 1) == BTYPE_AIR) { | ||||
|         AddZPlusVertices(vd, count, bt, x, y, z, u, v, s); | ||||
|     } | ||||
|     if (world->BlockAt(cx, y, cy - 1) == BTYPE_AIR) { | ||||
|         AddZMinusVertices(vd, count, bt, x, y, z, u, v, s); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Chunk::FlushMeshToVBO() { | ||||
|     m_vertexBuffer.SetMeshData(m_vd, m_vcount); | ||||
|     m_vcount = 0; | ||||
| @@ -181,47 +202,66 @@ void Chunk::AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType b | ||||
|  | ||||
|     int cx = x + (m_posX - cex) * CHUNK_SIZE_X, cy = z + (m_posY - cey) * CHUNK_SIZE_Z; | ||||
|  | ||||
|     if (y == CHUNK_SIZE_Y - 1 || GetBlock(x, y + 1, z) == BTYPE_AIR) {                      //  y | ||||
|     bool isOnBorder = (x == 0 || x == CHUNK_SIZE_X - 1 || | ||||
|                        z == 0 || z == CHUNK_SIZE_Z - 1 || | ||||
|                        y == 0 || y == CHUNK_SIZE_Y - 1); | ||||
|  | ||||
|     NEIGHBOR_CHUNK_POSITION ncp = CheckNeighbors(x, z, world); | ||||
|  | ||||
|     if (y == CHUNK_SIZE_Y - 1 || GetBlock(x, y + 1, z) == BTYPE_AIR) {                                              // Y+ | ||||
|         vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, .8f, .8f, .8f, u, v); | ||||
|         vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .8f, .8f, .8f, u, v + s); | ||||
|         vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .8f, .8f, .8f, u + s, v + s); | ||||
|         vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, .8f, .8f, .8f, u + s, v); | ||||
|     } | ||||
|  | ||||
|     if (y == 0 || GetBlock(x, y - 1, z) == BTYPE_AIR) {                                     // -y | ||||
|     if (y == 0 || GetBlock(x, y - 1, z) == BTYPE_AIR) {                                                             // Y- | ||||
|         vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .2f, .2f, .2f, u, v); | ||||
|         vd[count++] = VertexBuffer::VertexData(x, y, z, .2f, .2f, .2f, u, v + s); | ||||
|         vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z, .2f, .2f, .2f, u + s, v + s); | ||||
|         vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .2f, .2f, .2f, u + s, v); | ||||
|     } | ||||
|  | ||||
|     if (world->BlockAt(cx + 1, y, cy) == BTYPE_AIR) {                      //  x | ||||
|     if (!isOnBorder || (x == CHUNK_SIZE_X - 1 && ncp == X_PLUS) || (x == CHUNK_SIZE_X - 1 && ncp == NONE)) {        // X+ | ||||
|         AddAllVertices(vd, count, bt, cx, cy, x, y, z, u, v, s, world); | ||||
|     } | ||||
|     else if (!isOnBorder || (x == 0 && ncp == X_MINUS) || (x == 0 && ncp == NONE)) {							    // X- | ||||
|         AddAllVertices(vd, count, bt, cx, cy, x, y, z, u, v, s, world); | ||||
| 	} | ||||
|     else if (!isOnBorder || (z == CHUNK_SIZE_Z - 1 && ncp == Z_PLUS) || (z == CHUNK_SIZE_Z - 1 && ncp == NONE)) {	// Z+ | ||||
|         AddAllVertices(vd, count, bt, cx, cy, x, y, z, u, v, s, world); | ||||
| 	} | ||||
|     else if (!isOnBorder || (z == 0 && ncp == Z_MINUS) || (z == 0 && ncp == NONE)) {								// Z- | ||||
|         AddAllVertices(vd, count, bt, cx, cy, x, y, z, u, v, s, world); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Chunk::AddXPlusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s) { | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z, .9f, .9f, .9f, u, v); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, .9f, .9f, .9f, u, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .9f, .9f, .9f, u + s, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .9f, .9f, .9f, u + s, v); | ||||
|     } | ||||
| } | ||||
|  | ||||
|     if (world->BlockAt(cx - 1, y, cy) == BTYPE_AIR) {                                     // -x | ||||
| void Chunk::AddXMinusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s) { | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .5f, .5f, .5f, u, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, .5f, .5f, .5f, u + s, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y, z, .5f, .5f, .5f, u + s, v); | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .5f, .5f, .5f, u, v); | ||||
|     } | ||||
| } | ||||
|  | ||||
|     if (world->BlockAt(cx, y, cy + 1) == BTYPE_AIR) {                      //  z | ||||
| void Chunk::AddZPlusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s) { | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .4f, .4f, .4f, u, v); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .4f, .4f, .4f, u + s, v); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .4f, .4f, .4f, u + s, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .4f, .4f, .4f, u, v + s); | ||||
|     } | ||||
| } | ||||
|  | ||||
|     if (world->BlockAt(cx, y, cy - 1) == BTYPE_AIR) {                                     // -z | ||||
| void Chunk::AddZMinusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s) { | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, 1.f, 1.f, 1.f, u, v + s); | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, 1.f, 1.f, 1.f, u + s, v + s); | ||||
|         vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z , 1.f, 1.f, 1.f, u + s, v); | ||||
|         vd[count++] = VertexBuffer::VertexData(x, y, z , 1.f, 1.f, 1.f, u, v); | ||||
|     } | ||||
|     vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z, 1.f, 1.f, 1.f, u + s, v); | ||||
|     vd[count++] = VertexBuffer::VertexData(x, y, z, 1.f, 1.f, 1.f, u, v); | ||||
| } | ||||
|  | ||||
| void Chunk::Render() const { m_vertexBuffer.Render(); } | ||||
|   | ||||
| @@ -31,9 +31,14 @@ class Chunk { | ||||
|         void RemoveBlock(int x, int y, int z, World* world); | ||||
|         void SetBlock(int x, int y, int z, BlockType type, World* world); | ||||
|         BlockType GetBlock(int x, int y, int z); | ||||
|         void CheckNeighbors(unsigned int x, unsigned int z, World* world); | ||||
|         NEIGHBOR_CHUNK_POSITION CheckNeighbors(unsigned int x, unsigned int z, World* world); | ||||
|         void GetPosition(unsigned int& x, unsigned int& y) const; | ||||
|  | ||||
|         void AddAllVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt,int cx, int cy, int x, int y, int z, float u, float v, float s, World* world); | ||||
|         void AddXPlusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s); | ||||
|         void AddXMinusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s); | ||||
|         void AddZPlusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s); | ||||
|         void AddZMinusVertices(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s); | ||||
|  | ||||
|         void Update(BlockInfo* blockinfo[BTYPE_LAST], World* world); | ||||
|         void FlushMeshToVBO(); | ||||
|   | ||||
| @@ -4,7 +4,6 @@ | ||||
| #include <SFML/Window.hpp> | ||||
| #include <SFML/Graphics.hpp> | ||||
| #include <iostream> | ||||
| #include <iomanip> | ||||
|  | ||||
| #ifdef _WIN32 | ||||
| #include <windows.h> | ||||
| @@ -20,8 +19,8 @@ | ||||
| #define SEED 12345 | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define WORLD_SIZE_X 64 | ||||
| #define WORLD_SIZE_Y 64 | ||||
| #define WORLD_SIZE_X 2 | ||||
| #define WORLD_SIZE_Y 2 | ||||
|  | ||||
| #define FRAMES_RENDER_CHUNKS 4 | ||||
| #define FRAMES_UPDATE_CHUNKS 4 | ||||
| @@ -34,15 +33,14 @@ | ||||
| #define VIEW_DISTANCE 256 | ||||
| #define TEXTURE_SIZE 128 | ||||
| #define MAX_BULLETS 64 | ||||
| #define COUNTDOWN 300 | ||||
|  | ||||
| #define BASE_WIDTH 640 | ||||
| #define BASE_HEIGHT 480 | ||||
| #endif | ||||
|  | ||||
| #ifdef NDEBUG | ||||
| #define WORLD_SIZE_X 16 | ||||
| #define WORLD_SIZE_Y 16 | ||||
| #define WORLD_SIZE_X 2 | ||||
| #define WORLD_SIZE_Y 2 | ||||
|  | ||||
| #define FRAMES_RENDER_CHUNKS 1 | ||||
| #define FRAMES_UPDATE_CHUNKS 1 | ||||
| @@ -60,6 +58,7 @@ | ||||
|  | ||||
| typedef uint8_t BlockType; | ||||
| enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST }; | ||||
| enum NEIGHBOR_CHUNK_POSITION { NONE, X_MINUS, X_PLUS, Z_MINUS, Z_PLUS }; | ||||
|  | ||||
| //#define TEXTURE_PATH        "../SQCSim2021/media/textures/" | ||||
| //#define SHADER_PATH		    "../SQCSim2021/media/shaders/" | ||||
|   | ||||
| @@ -4,24 +4,6 @@ | ||||
| #include "transformation.h" | ||||
| #include "player.h" | ||||
|  | ||||
| #include <iostream> | ||||
| #include <chrono> | ||||
| #include <thread> | ||||
| #include <queue> | ||||
|  | ||||
|  | ||||
|  | ||||
| // Define a structure to represent notifications | ||||
| struct Notification { | ||||
| 	std::string message; | ||||
| 	float displayStartTime = 0.0f; | ||||
| }; | ||||
|  | ||||
| // Use a queue to manage notifications | ||||
| //std::queue<Notification> notificationQueue; | ||||
| // Use a vector to manage notifications | ||||
| std::vector<Notification> notifications; | ||||
|  | ||||
| Engine::Engine() {} | ||||
|  | ||||
| Engine::~Engine() { | ||||
| @@ -118,91 +100,6 @@ void Engine::LoadResource() { | ||||
|  | ||||
| void Engine::UnloadResource() {} | ||||
|  | ||||
| void Engine::SystemNotification(std::string systemLog) { | ||||
| 	std::string message = ""; | ||||
|  | ||||
| 	message = systemLog; | ||||
|  | ||||
| 	DisplayNotification(message); | ||||
| } | ||||
| void Engine::KillNotification(Player killer, Player killed) { | ||||
| 	std::string message = ""; | ||||
|  | ||||
| 	message = killed.GetUsername() + " killed by -> " + killer.GetUsername(); | ||||
|  | ||||
| 	DisplayNotification(message); | ||||
| } | ||||
|  | ||||
|  | ||||
| void Engine::DisplayNotification(std::string message) { | ||||
|  | ||||
| 	if (message.length() > 45) { | ||||
| 		message = message.substr(0, 45); | ||||
| 	} | ||||
| 	// Create a new notification and add it to the queue | ||||
| 	Notification newNotification; | ||||
| 	newNotification.message = message; | ||||
| 	newNotification.displayStartTime = m_time; | ||||
| 	 | ||||
| 	notifications.push_back(newNotification); | ||||
| } | ||||
|  | ||||
| // Add a method to process the notification queue | ||||
| void Engine::ProcessNotificationQueue() { | ||||
| 	m_textureFont.Bind(); | ||||
| 	float scale = GetScale() / 2.0f; | ||||
| 	unsigned int xOffset = Width() - Width() * 0.26; | ||||
| 	unsigned int yOffset = Height() - (Height() / 2.2); | ||||
|  | ||||
| 	// Iterate through the notifications and display them | ||||
| 	for (auto it = notifications.begin(); it != notifications.end(); ) { | ||||
| 		float timeSinceDisplay = m_time - it->displayStartTime; | ||||
|  | ||||
| 		// Display the notification message with vertical offset | ||||
| 		unsigned int y = yOffset - (static_cast<unsigned int>(scale * 20) * (it - notifications.begin())); | ||||
| 		glDisable(GL_STENCIL_TEST); | ||||
| 		glDisable(GL_DEPTH_TEST); | ||||
|  | ||||
| 		glBlendFunc(GL_SRC_ALPHA, GL_ONE); | ||||
| 		glBlendEquation(GL_FUNC_ADD); | ||||
|  | ||||
| 		glMatrixMode(GL_PROJECTION); | ||||
| 		glPushMatrix(); | ||||
|  | ||||
| 		glLoadIdentity(); | ||||
| 		glOrtho(0, Width(), 0, Height(), -1, 1); | ||||
|  | ||||
| 		glMatrixMode(GL_MODELVIEW); | ||||
| 		glPushMatrix(); | ||||
| 		 | ||||
| 		 | ||||
| 		 | ||||
| 		PrintText(xOffset, y, scale, it->message); | ||||
|  | ||||
| 		glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); | ||||
| 		glBlendEquation(GL_FUNC_SUBTRACT); | ||||
|  | ||||
| 		glEnable(GL_STENCIL_TEST); | ||||
| 		glEnable(GL_DEPTH_TEST); | ||||
|  | ||||
| 		glMatrixMode(GL_PROJECTION); | ||||
| 		glPopMatrix(); | ||||
|  | ||||
| 		glMatrixMode(GL_MODELVIEW); | ||||
| 		glPopMatrix(); | ||||
| 		// Check if it's time to remove the notification (display for 2 seconds) | ||||
| 		if (timeSinceDisplay >= 4.0f) { | ||||
| 			it = notifications.erase(it);  // Remove the notification | ||||
| 		} | ||||
| 		else { | ||||
| 			++it; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void Engine::DisplayCrosshair() { | ||||
| 	m_textureCrosshair.Bind(); | ||||
| 	static const int crossSize = 32; | ||||
| @@ -223,7 +120,7 @@ void Engine::DisplayCrosshair() { | ||||
| void Engine::DisplayCurrentItem() { | ||||
| } | ||||
|  | ||||
| void Engine::DisplayHud(int timer) { | ||||
| void Engine::DisplayHud() { | ||||
| 	glBindTexture(GL_TEXTURE_2D, 0); | ||||
| 	glLoadIdentity(); | ||||
| 	glDisable(GL_BLEND); | ||||
| @@ -289,13 +186,6 @@ void Engine::DisplayHud(int timer) { | ||||
| 	std::ostringstream ss; | ||||
| 	ss << m_player.GetUsername(); | ||||
| 	PrintText(fPosX, fPosY, scale, ss.str()); | ||||
|  | ||||
| 	//Countdown | ||||
| 	ss.str(""); | ||||
| 	ss << "Time: " << (int)(timer / 60) << ":" << std::setw(2) << std::setfill('0') << timer % 60; | ||||
| 	PrintText(Width() - Width() * 0.15, Height() - (Height() / 19.2), scale, ss.str()); | ||||
| 	 | ||||
|  | ||||
| } | ||||
|  | ||||
| void Engine::DisplayInfo(float elapsedTime, BlockType bloc) { | ||||
| @@ -350,25 +240,13 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) { | ||||
| 	glMatrixMode(GL_MODELVIEW); | ||||
| 	glPushMatrix(); | ||||
|  | ||||
| 	int timer = GetCountdown(elapsedTime); | ||||
|  | ||||
| 	// Appel de la fonction pour l'affichage de notifications | ||||
| 	if (m_keyK) { | ||||
| 		SystemNotification(m_messageNotification); | ||||
| 		m_keyK = false; | ||||
| 	} | ||||
| 	if (m_keyL) { | ||||
| 		 | ||||
| 		KillNotification(m_player, m_player); | ||||
| 		m_keyL = false; | ||||
| 	} | ||||
|  | ||||
| 	if (m_displayInfo) { | ||||
| 		DisplayInfo(elapsedTime, bloc); | ||||
| 	} | ||||
|  | ||||
| 	if (m_displayHud) { | ||||
| 		DisplayHud(timer); | ||||
| 		DisplayHud(); | ||||
| 	} | ||||
|  | ||||
| 	if (m_displayCrosshair) { | ||||
| @@ -417,18 +295,6 @@ float Engine::GetScale() const { | ||||
| } | ||||
|  | ||||
| int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; } | ||||
| int Engine::GetCountdown(float elapsedTime) { | ||||
| 	if (m_resetcountdown) | ||||
| 	{ | ||||
| 		m_countdown = m_time + COUNTDOWN; | ||||
| 		m_resetcountdown = false; | ||||
| 	} | ||||
| 	if (m_countdown < m_time) | ||||
| 		Stop(); | ||||
| 	if(!m_stopcountdown) | ||||
| 		m_time += elapsedTime; | ||||
| 	return m_countdown - (int)m_time; | ||||
| } | ||||
|  | ||||
| void Engine::Render(float elapsedTime) { | ||||
| 	//static float gameTime = elapsedTime; | ||||
| @@ -507,7 +373,6 @@ void Engine::Render(float elapsedTime) { | ||||
|  | ||||
| 	if (m_isSkybox) m_skybox.Render(skybox); | ||||
|  | ||||
| 	ProcessNotificationQueue(); | ||||
| 	DrawHud(elapsedTime, bloc); | ||||
| 	 | ||||
| 	static bool fell = false; | ||||
| @@ -559,15 +424,6 @@ void Engine::KeyPressEvent(unsigned char key) { | ||||
| 		break; | ||||
| 	case 5: // F - Ignorer | ||||
| 		break; | ||||
| 	case 10: // K - Debugging DisplayNotification() | ||||
| 		m_keyK = true; | ||||
| 		m_messageNotification = "notifications systeme peuvent <20>tre affich<63>"; | ||||
| 		break; | ||||
| 	case 11: // L - Debugging DisplayNotification() | ||||
| 		m_keyL = true; | ||||
| 		break; | ||||
| 	case 6: // G - Ignorer | ||||
| 		break; | ||||
| 	case 12: // M - Ignorer | ||||
| 		break; | ||||
| 	case 7: // H - Ignorer | ||||
| @@ -576,8 +432,6 @@ void Engine::KeyPressEvent(unsigned char key) { | ||||
| 		break; | ||||
| 	case 17: // R - Ignorer | ||||
| 		break; | ||||
| 	case 19: // T - Ignorer | ||||
| 		break;  | ||||
| 	case 24: // Y - Ignorer | ||||
| 		break; | ||||
| 	case 255: // Fn - Ignorer | ||||
| @@ -602,10 +456,6 @@ void Engine::KeyReleaseEvent(unsigned char key) { | ||||
| 	case 5: // F - Toggle flash | ||||
| 		m_flash = !m_flash; | ||||
| 		break; | ||||
| 	case 6: // G - Toggle Stop Countdown | ||||
| 		m_stopcountdown = !m_stopcountdown; | ||||
| 		std::cout << "STOP COUNTDOWN " << (m_stopcountdown ? "enabled" : "disabled") << std::endl; | ||||
| 		break; | ||||
| 	case 7: // H - Toggle HUD | ||||
| 		m_displayHud = !m_displayHud; | ||||
| 		std::cout << "DISPLAY HUD " << (m_displayHud ? "enabled" : "disabled") << std::endl; | ||||
| @@ -614,12 +464,6 @@ void Engine::KeyReleaseEvent(unsigned char key) { | ||||
| 		m_displayInfo = !m_displayInfo; | ||||
| 		std::cout << "DISPLAY INFO " << (m_displayInfo ? "enabled" : "disabled") << std::endl; | ||||
| 		break; | ||||
| 	case 10: // K | ||||
| 		m_keyK = false; | ||||
| 		break; | ||||
| 	case 11: // L - Debugging DisplayNotification() | ||||
| 		m_keyL = false; | ||||
| 		break; | ||||
| 	case 12: // M - Toggle music | ||||
| 		m_audio.ToggleMusicState(); | ||||
| 		break; | ||||
| @@ -629,10 +473,6 @@ void Engine::KeyReleaseEvent(unsigned char key) { | ||||
| 	case 18: // S - Stop reculer | ||||
| 		m_keyS = false; | ||||
| 		break; | ||||
| 	case 19: // T -Reset countdown | ||||
| 		m_resetcountdown = true; | ||||
| 		std::cout << "RESET COUNTDOWN" << std::endl; | ||||
| 		break; | ||||
| 	case 22: // W - Stop avancer | ||||
| 		m_keyW = false; | ||||
| 		break; | ||||
|   | ||||
| @@ -35,17 +35,12 @@ private: | ||||
|     float GetScale() const; | ||||
|  | ||||
|     int GetFps(float elapsedTime) const; | ||||
|     int GetCountdown(float elapsedTime); | ||||
|  | ||||
|     bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true); | ||||
|  | ||||
|     void SystemNotification(std::string systemLog); | ||||
|     void KillNotification(Player killer, Player killed); | ||||
|     void DisplayNotification(std::string message); | ||||
|     void ProcessNotificationQueue(); | ||||
|     void DisplayCrosshair(); | ||||
|     void DisplayCurrentItem(); | ||||
|     void DisplayHud(int timer); | ||||
|     void DisplayHud(); | ||||
|     void DisplayInfo(float elapsedTime, BlockType bloc); | ||||
|     void DrawHud(float elapsedTime, BlockType bloc); | ||||
|     void PrintText(float x, float y, float scale, const std::string& t); | ||||
| @@ -72,10 +67,8 @@ private: | ||||
|     Bullet* m_bullets[MAX_BULLETS]; | ||||
|  | ||||
|     float m_scale; | ||||
|     float m_time = 0; | ||||
|  | ||||
|     int m_renderCount = 0; | ||||
|     int m_countdown = COUNTDOWN; | ||||
|  | ||||
|     bool m_wireframe = false; | ||||
|     bool m_isSkybox = true; | ||||
| @@ -84,11 +77,7 @@ private: | ||||
|     bool m_displayCrosshair = true; | ||||
|     bool m_displayHud = true; | ||||
|     bool m_displayInfo = false; | ||||
|     bool m_resetcountdown = false; | ||||
|     bool m_stopcountdown = false; | ||||
|      | ||||
|     bool m_keyK = false; | ||||
|     bool m_keyL = false; | ||||
|     bool m_keyW = false; | ||||
|     bool m_keyA = false; | ||||
|     bool m_keyS = false; | ||||
| @@ -99,8 +88,6 @@ private: | ||||
|     bool m_mouseC = false; | ||||
|     bool m_mouseWU = false; | ||||
|     bool m_mouseWD = false; | ||||
|  | ||||
|     std::string m_messageNotification = ""; | ||||
| }; | ||||
|  | ||||
| #endif // ENGINE_H__ | ||||
|   | ||||
| Before Width: | Height: | Size: 262 KiB | 
| Before Width: | Height: | Size: 261 KiB | 
| Before Width: | Height: | Size: 363 KiB | 
| Before Width: | Height: | Size: 363 KiB | 
| Before Width: | Height: | Size: 249 KiB | 
| Before Width: | Height: | Size: 308 KiB | 
| Before Width: | Height: | Size: 370 KiB | 
| Before Width: | Height: | Size: 370 KiB | 
| Before Width: | Height: | Size: 249 KiB | 
| Before Width: | Height: | Size: 308 KiB | 
| Before Width: | Height: | Size: 254 KiB | 
| Before Width: | Height: | Size: 255 KiB | 
| Before Width: | Height: | Size: 270 KiB | 
| Before Width: | Height: | Size: 269 KiB | 
| Before Width: | Height: | Size: 310 KiB | 
| Before Width: | Height: | Size: 310 KiB | 
| Before Width: | Height: | Size: 359 KiB | 
| Before Width: | Height: | Size: 360 KiB | 
| Before Width: | Height: | Size: 367 KiB | 
| Before Width: | Height: | Size: 368 KiB | 
| Before Width: | Height: | Size: 327 KiB | 
| Before Width: | Height: | Size: 348 KiB | 
| Before Width: | Height: | Size: 382 KiB | 
| Before Width: | Height: | Size: 327 KiB | 
| Before Width: | Height: | Size: 329 KiB | 
| Before Width: | Height: | Size: 362 KiB | 
| Before Width: | Height: | Size: 641 KiB | 
| Before Width: | Height: | Size: 654 KiB | 
| Before Width: | Height: | Size: 651 KiB | 
| Before Width: | Height: | Size: 640 KiB | 
| Before Width: | Height: | Size: 654 KiB | 
| Before Width: | Height: | Size: 650 KiB | 
| Before Width: | Height: | Size: 474 KiB | 
| Before Width: | Height: | Size: 501 KiB | 
| Before Width: | Height: | Size: 563 KiB | 
| Before Width: | Height: | Size: 473 KiB | 
| Before Width: | Height: | Size: 500 KiB | 
| Before Width: | Height: | Size: 563 KiB | 
| Before Width: | Height: | Size: 698 KiB | 
| Before Width: | Height: | Size: 719 KiB | 
| Before Width: | Height: | Size: 735 KiB | 
| Before Width: | Height: | Size: 698 KiB | 
| Before Width: | Height: | Size: 719 KiB | 
| Before Width: | Height: | Size: 735 KiB | 
| Before Width: | Height: | Size: 760 KiB | 
| Before Width: | Height: | Size: 783 KiB | 
| Before Width: | Height: | Size: 804 KiB | 
| Before Width: | Height: | Size: 760 KiB | 
| Before Width: | Height: | Size: 783 KiB | 
| Before Width: | Height: | Size: 804 KiB | 
| Before Width: | Height: | Size: 276 KiB | 
| Before Width: | Height: | Size: 276 KiB | 
| Before Width: | Height: | Size: 315 KiB | 
| Before Width: | Height: | Size: 315 KiB | 
| Before Width: | Height: | Size: 338 KiB | 
| Before Width: | Height: | Size: 395 KiB | 
| Before Width: | Height: | Size: 395 KiB | 
| Before Width: | Height: | Size: 338 KiB | 
| Before Width: | Height: | Size: 258 KiB | 
| Before Width: | Height: | Size: 258 KiB | 
| Before Width: | Height: | Size: 655 KiB | 
| Before Width: | Height: | Size: 658 KiB | 
| Before Width: | Height: | Size: 679 KiB | 
| Before Width: | Height: | Size: 654 KiB | 
| Before Width: | Height: | Size: 657 KiB | 
| Before Width: | Height: | Size: 678 KiB | 
| Before Width: | Height: | Size: 473 KiB | 
| Before Width: | Height: | Size: 481 KiB | 
| Before Width: | Height: | Size: 504 KiB | 
| Before Width: | Height: | Size: 474 KiB | 
| Before Width: | Height: | Size: 481 KiB | 
| Before Width: | Height: | Size: 505 KiB | 
| Before Width: | Height: | Size: 688 KiB | 
| Before Width: | Height: | Size: 701 KiB | 
| Before Width: | Height: | Size: 715 KiB | 
| Before Width: | Height: | Size: 843 KiB | 
| Before Width: | Height: | Size: 874 KiB | 
| Before Width: | Height: | Size: 891 KiB | 
| Before Width: | Height: | Size: 842 KiB | 
| Before Width: | Height: | Size: 874 KiB | 
| Before Width: | Height: | Size: 891 KiB | 
| Before Width: | Height: | Size: 688 KiB | 
| Before Width: | Height: | Size: 701 KiB | 
| Before Width: | Height: | Size: 715 KiB | 
| Before Width: | Height: | Size: 397 KiB | 
| Before Width: | Height: | Size: 390 KiB | 
| Before Width: | Height: | Size: 400 KiB | 
| Before Width: | Height: | Size: 398 KiB | 
| Before Width: | Height: | Size: 389 KiB | 
| Before Width: | Height: | Size: 400 KiB | 
| Before Width: | Height: | Size: 244 KiB | 
| Before Width: | Height: | Size: 244 KiB | 
| Before Width: | Height: | Size: 345 KiB | 
| Before Width: | Height: | Size: 345 KiB | 
| Before Width: | Height: | Size: 315 KiB |