Compare commits
	
		
			3 Commits
		
	
	
		
			sqc-20_aud
			...
			L-CSplash
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | f8680a318a | ||
|  | f4d4f1eca0 | ||
|  | 793da52871 | 
| @@ -28,6 +28,56 @@ Engine::~Engine() { | |||||||
| 				m_world.GetChunks().Get(x, y)->~Chunk(); | 				m_world.GetChunks().Get(x, y)->~Chunk(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void Engine::DrawSplachScreen() | ||||||
|  | { | ||||||
|  | 	glDisable(GL_LIGHTING); | ||||||
|  | 	glDisable(GL_DEPTH_TEST); | ||||||
|  | 	glDisable(GL_STENCIL_TEST); | ||||||
|  |  | ||||||
|  | 	// Définir la matrice de projection en mode orthographique | ||||||
|  | 	glMatrixMode(GL_PROJECTION); | ||||||
|  | 	glPushMatrix(); | ||||||
|  | 	glLoadIdentity(); | ||||||
|  | 	glOrtho(-Width() / 2, Width() / 2, -Height() / 2, Height() / 2, -1, 1); | ||||||
|  |  | ||||||
|  | 	// Définir la matrice de modèle-vue | ||||||
|  | 	glMatrixMode(GL_MODELVIEW); | ||||||
|  | 	glPushMatrix(); | ||||||
|  | 	glLoadIdentity(); | ||||||
|  |  | ||||||
|  | 	// L'image sera centrée autour de l'origine (0, 0, 0) | ||||||
|  | 	int imageWidth = Width(); // Remplacez par la largeur de votre image | ||||||
|  | 	int imageHeight = Height(); // Remplacez par la hauteur de votre image | ||||||
|  |  | ||||||
|  | 	// Texture | ||||||
|  | 	SplachScreenTexture.Bind(); | ||||||
|  |  | ||||||
|  | 	// Dessiner un quadrilatère centré | ||||||
|  | 	glBegin(GL_QUADS); | ||||||
|  | 	glTexCoord2f(0, 0); | ||||||
|  | 	glVertex2i(-imageWidth / 2, -imageHeight / 2); | ||||||
|  | 	glTexCoord2f(1, 0); | ||||||
|  | 	glVertex2i(imageWidth / 2, -imageHeight / 2); | ||||||
|  | 	glTexCoord2f(1, 1); | ||||||
|  | 	glVertex2i(imageWidth / 2, imageHeight / 2); | ||||||
|  | 	glTexCoord2f(0, 1); | ||||||
|  | 	glVertex2i(-imageWidth / 2, imageHeight / 2); | ||||||
|  | 	glEnd(); | ||||||
|  |  | ||||||
|  | 	// Activer la transparence | ||||||
|  | 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||||
|  | 	glBlendEquation(GL_FUNC_ADD); | ||||||
|  | 	glEnable(GL_BLEND); | ||||||
|  |  | ||||||
|  | 	// Restaurer les matrices précédentes | ||||||
|  | 	glMatrixMode(GL_PROJECTION); | ||||||
|  | 	glPopMatrix(); | ||||||
|  | 	glMatrixMode(GL_MODELVIEW); | ||||||
|  | 	glPopMatrix(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void Engine::DrawMenu() | void Engine::DrawMenu() | ||||||
| { | { | ||||||
| 	static const int sTitle = 400; | 	static const int sTitle = 400; | ||||||
| @@ -223,6 +273,8 @@ void Engine::DrawMenu() | |||||||
| } | } | ||||||
|  |  | ||||||
| void Engine::Init() { | void Engine::Init() { | ||||||
|  |  | ||||||
|  |  | ||||||
| 	GLenum glewErr = glewInit(); | 	GLenum glewErr = glewInit(); | ||||||
| 	if (glewErr != GLEW_OK) { | 	if (glewErr != GLEW_OK) { | ||||||
| 		std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl; | 		std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl; | ||||||
| @@ -298,6 +350,7 @@ void Engine::LoadResource() { | |||||||
|  |  | ||||||
| 	LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png"); | 	LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png"); | ||||||
| 	LoadTexture(MenuBGTexture, MENU_ITEM_PATH "test.png"); | 	LoadTexture(MenuBGTexture, MENU_ITEM_PATH "test.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"); | ||||||
| @@ -649,7 +702,10 @@ int Engine::GetCountdown(float elapsedTime) { | |||||||
| void Engine::Render(float elapsedTime) { | void Engine::Render(float elapsedTime) { | ||||||
| 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | ||||||
|  |  | ||||||
| 	if (m_gamestate == GameState::PLAY) | 	m_time_SplashScreen += elapsedTime; | ||||||
|  | 	if(m_time_SplashScreen < 2) | ||||||
|  | 	DrawSplachScreen(); | ||||||
|  | 	else if (m_gamestate == GameState::PLAY) | ||||||
| 	{ | 	{ | ||||||
| 		HideCursor(); | 		HideCursor(); | ||||||
| 		CenterMouse(); //D<>placement de centermouse dans l'action de jouer | 		CenterMouse(); //D<>placement de centermouse dans l'action de jouer | ||||||
| @@ -684,11 +740,11 @@ void Engine::Render(float elapsedTime) { | |||||||
| 				if (leftright) | 				if (leftright) | ||||||
| 					vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x); | 					vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x); | ||||||
| 				else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x); | 				else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x); | ||||||
| 				m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), .8f); | 				m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false,.8f); | ||||||
| 				leftright = !leftright; | 				leftright = !leftright; | ||||||
| 				break; | 				break; | ||||||
| 			case Player::Sound::FALL: | 			case Player::Sound::FALL: | ||||||
| 				m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f); | 				m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false,1.f); | ||||||
| 				break; | 				break; | ||||||
| 			default: break; | 			default: break; | ||||||
| 			} | 			} | ||||||
| @@ -755,7 +811,7 @@ void Engine::Render(float elapsedTime) { | |||||||
|  |  | ||||||
| 		static bool fell = false; | 		static bool fell = false; | ||||||
| 		if (m_player.GetPosition().y < 1.7f && !fell) { | 		if (m_player.GetPosition().y < 1.7f && !fell) { | ||||||
| 			m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f); | 			m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false,1.f); | ||||||
| 			fell = true; | 			fell = true; | ||||||
| 		} | 		} | ||||||
| 		else if (m_player.GetPosition().y < -20.f) { | 		else if (m_player.GetPosition().y < -20.f) { | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ public: | |||||||
|     Engine(); |     Engine(); | ||||||
|     virtual ~Engine(); |     virtual ~Engine(); | ||||||
|     virtual void DrawMenu(); |     virtual void DrawMenu(); | ||||||
|  |     virtual void DrawSplachScreen(); | ||||||
|     virtual void Init(); |     virtual void Init(); | ||||||
|     virtual void DeInit(); |     virtual void DeInit(); | ||||||
|     virtual void LoadResource(); |     virtual void LoadResource(); | ||||||
| @@ -87,9 +88,13 @@ private: | |||||||
|     Texture MenuStartTexture; |     Texture MenuStartTexture; | ||||||
|     Texture MenuQuitTexture; |     Texture MenuQuitTexture; | ||||||
|     Texture MenuOptionsTexture; |     Texture MenuOptionsTexture; | ||||||
|  |     Texture SplachScreenTexture; | ||||||
|  |  | ||||||
|     float m_scale; |     float m_scale; | ||||||
|     float m_time = 0; |     float m_time = 0; | ||||||
|  |     float m_time_SplashScreen = 0; | ||||||
|  |     float m_Width = 0; | ||||||
|  |     float m_Height = 0; | ||||||
|  |  | ||||||
|     int m_renderCount = 0; |     int m_renderCount = 0; | ||||||
|     int m_countdown = COUNTDOWN; |     int m_countdown = COUNTDOWN; | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/sc2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/sc2.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 195 KiB | 
| @@ -9,6 +9,7 @@ OpenglContext::~OpenglContext() | |||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| bool OpenglContext::Start(const std::string& title, int width, int height, bool fullscreen) | bool OpenglContext::Start(const std::string& title, int width, int height, bool fullscreen) | ||||||
| { | { | ||||||
|     m_title = title; |     m_title = title; | ||||||
| @@ -22,6 +23,7 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool | |||||||
|  |  | ||||||
|     while (m_app.isOpen()) |     while (m_app.isOpen()) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|             clock.restart(); |             clock.restart(); | ||||||
|  |  | ||||||
|             sf::Event Event; |             sf::Event Event; | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ | |||||||
| #include <string> | #include <string> | ||||||
| #include <SFML/Window.hpp> | #include <SFML/Window.hpp> | ||||||
| #include "define.h" | #include "define.h" | ||||||
|  | #include "texture.h" | ||||||
|  |  | ||||||
| // Documentation de SFML: http://www.sfml-dev.org/documentation/index-fr.php | // Documentation de SFML: http://www.sfml-dev.org/documentation/index-fr.php | ||||||
| class OpenglContext | class OpenglContext | ||||||
| @@ -31,7 +32,6 @@ public: | |||||||
|     virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y) = 0; |     virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y) = 0; | ||||||
|     virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y) = 0; |     virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y) = 0; | ||||||
|  |  | ||||||
|  |  | ||||||
|     bool Start(const std::string& title, int width, int height, bool fullscreen); |     bool Start(const std::string& title, int width, int height, bool fullscreen); | ||||||
|     bool Stop(); |     bool Stop(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user