Créé branche
This commit is contained in:
parent
793da52871
commit
f4d4f1eca0
@ -684,11 +684,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 +755,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) {
|
||||||
|
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,11 +9,43 @@ OpenglContext::~OpenglContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenglContext::RenderSplashScreen()
|
||||||
|
{
|
||||||
|
m_textureSplash.Load(TEXTURE_PATH "sc2.png", true);
|
||||||
|
|
||||||
|
if (!m_textureSplash.IsValid()) {
|
||||||
|
std::cerr << "Unable to load texture sc2.png" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_textureSplash.Bind();
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Utilisez une fonction de mélange appropriée
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2i(0, 0);
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2i(BASE_WIDTH, 0);
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2i(BASE_WIDTH, BASE_HEIGHT);
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2i(0, BASE_HEIGHT);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
m_fullscreen = fullscreen;
|
m_fullscreen = fullscreen;
|
||||||
InitWindow(width, height);
|
InitWindow(width, height);
|
||||||
|
bool showSplashScreen = true;
|
||||||
|
sf::Clock splashClock;
|
||||||
|
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
LoadResource();
|
LoadResource();
|
||||||
@ -22,13 +54,29 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
|||||||
|
|
||||||
while (m_app.isOpen())
|
while (m_app.isOpen())
|
||||||
{
|
{
|
||||||
clock.restart();
|
if (showSplashScreen)
|
||||||
|
|
||||||
sf::Event Event;
|
|
||||||
while (m_app.pollEvent(Event))
|
|
||||||
{
|
{
|
||||||
switch(Event.type)
|
m_app.setActive();
|
||||||
|
Render(m_lastFrameTime);
|
||||||
|
m_app.display();
|
||||||
|
RenderSplashScreen();
|
||||||
|
|
||||||
|
if (splashClock.getElapsedTime().asSeconds() >= 3)
|
||||||
{
|
{
|
||||||
|
showSplashScreen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
clock.restart();
|
||||||
|
|
||||||
|
sf::Event Event;
|
||||||
|
while (m_app.pollEvent(Event))
|
||||||
|
{
|
||||||
|
switch (Event.type)
|
||||||
|
{
|
||||||
case sf::Event::Closed:
|
case sf::Event::Closed:
|
||||||
m_app.close();
|
m_app.close();
|
||||||
break;
|
break;
|
||||||
@ -51,28 +99,29 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
|||||||
MouseReleaseEvent(ConvertMouseButton(Event.mouseButton.button), Event.mouseButton.x, Event.mouseButton.y);
|
MouseReleaseEvent(ConvertMouseButton(Event.mouseButton.button), Event.mouseButton.x, Event.mouseButton.y);
|
||||||
break;
|
break;
|
||||||
case sf::Event::MouseWheelMoved:
|
case sf::Event::MouseWheelMoved:
|
||||||
if(Event.mouseWheel.delta > 0)
|
if (Event.mouseWheel.delta > 0)
|
||||||
MousePressEvent(MOUSE_BUTTON_WHEEL_UP, Event.mouseButton.x, Event.mouseButton.y);
|
MousePressEvent(MOUSE_BUTTON_WHEEL_UP, Event.mouseButton.x, Event.mouseButton.y);
|
||||||
else
|
else
|
||||||
MousePressEvent(MOUSE_BUTTON_WHEEL_DOWN, Event.mouseButton.x, Event.mouseButton.y);
|
MousePressEvent(MOUSE_BUTTON_WHEEL_DOWN, Event.mouseButton.x, Event.mouseButton.y);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_app.setActive();
|
m_app.setActive();
|
||||||
Render(m_lastFrameTime);
|
Render(m_lastFrameTime);
|
||||||
m_app.display();
|
m_app.display();
|
||||||
|
|
||||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
|
||||||
|
|
||||||
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
|
||||||
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
|
||||||
if(waitTime > 0)
|
|
||||||
{
|
|
||||||
sf::sleep(sf::seconds(waitTime));
|
|
||||||
|
|
||||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||||
|
|
||||||
|
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
||||||
|
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
||||||
|
if (waitTime > 0)
|
||||||
|
{
|
||||||
|
sf::sleep(sf::seconds(waitTime));
|
||||||
|
|
||||||
|
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
@ -30,7 +31,7 @@ public:
|
|||||||
virtual void MouseMoveEvent(int x, int y) = 0;
|
virtual void MouseMoveEvent(int x, int y) = 0;
|
||||||
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;
|
||||||
|
virtual void RenderSplashScreen();
|
||||||
|
|
||||||
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();
|
||||||
@ -62,6 +63,7 @@ private:
|
|||||||
bool m_fullscreen;
|
bool m_fullscreen;
|
||||||
std::string m_title;
|
std::string m_title;
|
||||||
float m_lastFrameTime;
|
float m_lastFrameTime;
|
||||||
|
Texture m_textureSplash;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPENGLCONTEXT_H__
|
#endif // OPENGLCONTEXT_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user