Compare commits
15 Commits
escalade_d
...
affichage_
Author | SHA1 | Date | |
---|---|---|---|
|
54e2f32aba | ||
|
90fdc8ed1b | ||
|
f0912614a4 | ||
|
421632a0d7 | ||
|
15d3864e4a | ||
|
47d7fbfc27 | ||
|
1a215c823b | ||
|
9a0f162f33 | ||
|
703b432fb7 | ||
|
9aa426b804 | ||
|
cf75843117 | ||
|
e546de57c9 | ||
|
54ae0b087a | ||
|
8faa67596e | ||
|
f8ad857666 |
@@ -14,7 +14,7 @@ Audio::Audio(const char * music) {
|
||||
m_engine->setRolloffFactor(1);
|
||||
m_engine->setDefault3DSoundMinDistance(1);
|
||||
m_engine->setDefault3DSoundMaxDistance(1000);
|
||||
m_music = m_engine->play2D(music, true, true, true, irrklang::ESM_STREAMING);
|
||||
m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING);
|
||||
}
|
||||
|
||||
Audio::~Audio() {
|
||||
@@ -40,9 +40,9 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v
|
||||
sound->setVolume(volume);
|
||||
}
|
||||
|
||||
void Audio::PlaySong(const char* music) {
|
||||
m_music = m_engine->play2D(music, true, true, true, irrklang::ESM_STREAMING);
|
||||
}
|
||||
//void Audio::PlaySong(const char* music) {
|
||||
// m_music = m_engine->play2D(music, false, false, false, irrklang::ESM_STREAMING);
|
||||
//}
|
||||
|
||||
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
|
||||
|
||||
|
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
||||
|
||||
void PlaySong(const char* music);
|
||||
//void PlaySong(const char* music);
|
||||
|
||||
void ToggleMusicState();
|
||||
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -33,6 +34,10 @@
|
||||
#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
|
||||
|
@@ -4,6 +4,24 @@
|
||||
#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() {
|
||||
@@ -21,24 +39,25 @@ void Engine::Init() {
|
||||
abort();
|
||||
}
|
||||
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
//glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
//glEnable(GL_STENCIL_TEST);
|
||||
//glEnable(GL_POINT_SMOOTH);
|
||||
//glEnable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
|
||||
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
//glDisable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
//
|
||||
// Objet de skybox avec sa propre texture et son propre shader!
|
||||
m_skybox.Init(0.2f);
|
||||
|
||||
@@ -60,9 +79,11 @@ void Engine::Init() {
|
||||
void Engine::DeInit() {}
|
||||
|
||||
void Engine::LoadResource() {
|
||||
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png");
|
||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp");
|
||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp");
|
||||
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
||||
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
|
||||
|
||||
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
||||
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
||||
@@ -97,46 +118,92 @@ void Engine::LoadResource() {
|
||||
|
||||
void Engine::UnloadResource() {}
|
||||
|
||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
// Setter le blend function , tout ce qui sera noir sera transparent
|
||||
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);
|
||||
glColor4f(1.f, 1.f, 1.f, 1.f);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
// Bind de la texture pour le font
|
||||
m_textureFont.Bind();
|
||||
std::ostringstream ss;
|
||||
ss << " Fps : " << GetFps(elapsedTime);
|
||||
PrintText(10, Height() - 25, ss.str());
|
||||
ss.str("");
|
||||
ss << " Rendered Chunks : " << m_renderCount;
|
||||
PrintText(10, Height() - 35, ss.str());
|
||||
ss.str("");
|
||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
||||
PrintText(10, Height() - 45, ss.str());
|
||||
ss.str("");
|
||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
||||
PrintText(10, 10, ss.str());
|
||||
ss.str("");
|
||||
ss << " Direction : " << m_player.GetDirection();
|
||||
PrintText(10, 20, ss.str());
|
||||
ss.str("");
|
||||
ss << " Position : " << m_player.GetPosition();
|
||||
PrintText(10, 30, ss.str());
|
||||
ss.str("");
|
||||
ss << " Block : ";
|
||||
if (bloc == BTYPE_LAST)
|
||||
ss << "Weapon.";
|
||||
else ss << (int)bloc;
|
||||
PrintText(10, 40, ss.str());
|
||||
|
||||
|
||||
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;
|
||||
glLoadIdentity();
|
||||
@@ -151,38 +218,217 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, crossSize);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void Engine::DisplayCurrentItem() {
|
||||
}
|
||||
|
||||
void Engine::DisplayHud(int timer) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glLoadIdentity();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// Barre HP
|
||||
float fBarWidth = Width() / 4;
|
||||
float fBarHeight = Height() / 25;
|
||||
float fPosX = Width() / 20;
|
||||
float fPosY = Height() - (Height() - (fBarHeight * 4));
|
||||
float playerHp = m_player.GetHP();
|
||||
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
||||
|
||||
// Arri<72>re-plan (Barre HP)
|
||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
||||
glVertex2f(fPosX + fBarWidth, fPosY - fBarHeight); // Bas-Droite
|
||||
glVertex2f(fPosX + fBarWidth, fPosY); // Haut-Droite
|
||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||
glEnd();
|
||||
|
||||
//TODO: Associer avec m<>chanique de vie du joueur
|
||||
|
||||
// Barre HP
|
||||
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
||||
glVertex2f(fPosX + fBarWidth * playerHp, fPosY - fBarHeight); // Bas-Droite
|
||||
glVertex2f(fPosX + fBarWidth * playerHp, fPosY); // Haut-Droite
|
||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||
glEnd();
|
||||
|
||||
// Barre <20>quip
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||
m_textureGun.Bind();
|
||||
|
||||
float margin = Width() * 0.05;
|
||||
float itemWidth = Width() * 0.33;
|
||||
float itemHeight = itemWidth / 2.208;
|
||||
float startX = Width() - itemWidth - margin;
|
||||
float startY = margin;
|
||||
|
||||
glTranslated(startX, startY, 0);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(1, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(0, 0); glVertex2i(itemWidth, 0);
|
||||
glTexCoord2f(0, 1); glVertex2i(itemWidth, itemHeight);
|
||||
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// Username
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
float scale = GetScale();
|
||||
m_textureFont.Bind();
|
||||
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) {
|
||||
// Bind de la texture pour le font
|
||||
m_textureFont.Bind();
|
||||
std::ostringstream ss;
|
||||
|
||||
float scale = GetScale();
|
||||
unsigned int x = Width() / 25;
|
||||
|
||||
ss << " Fps : " << GetFps(elapsedTime);
|
||||
PrintText(x, Height() - (Height() / 19.2), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Rendered Chunks : " << m_renderCount;
|
||||
PrintText(x, Height() - (Height() / 13.7), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
||||
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
||||
PrintText(x, Height() / 48, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Direction : " << m_player.GetDirection();
|
||||
PrintText(x, Height() / 24, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Position : " << m_player.GetPosition();
|
||||
PrintText(x, Height() / 16, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Block : ";
|
||||
|
||||
if (bloc == BTYPE_LAST)
|
||||
ss << "Weapon.";
|
||||
else ss << (int)bloc;
|
||||
|
||||
PrintText(x, Height() / 12, scale, ss.str());
|
||||
}
|
||||
|
||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
// Setter le blend function, tout ce qui sera noir sera transparent
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (m_displayCrosshair) {
|
||||
DisplayCrosshair();
|
||||
}
|
||||
|
||||
// Reset du blend function
|
||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Engine::PrintText(unsigned int x, unsigned int y, const std::string& t) {
|
||||
void Engine::PrintText(float x, float y, float scale, const std::string& t) {
|
||||
glLoadIdentity();
|
||||
glTranslated(x, y, 0);
|
||||
|
||||
for (unsigned int i = 0; i < t.length(); ++i) {
|
||||
float left = (float)((t[i] - 32) % 16) / 16.f;
|
||||
float top = (float)((t[i] - 32) / 16) / 16.f;
|
||||
top += .5f;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(left, 1.f - top - .0625f);
|
||||
glVertex2f(0, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top - .0625f);
|
||||
glVertex2f(12, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top);
|
||||
glVertex2f(12, 12);
|
||||
glTexCoord2f(left, 1.f - top);
|
||||
glVertex2f(0, 12);
|
||||
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(12 * scale, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12 * scale, 12 * scale);
|
||||
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12 * scale);
|
||||
glEnd();
|
||||
glTranslated(8, 0, 0);
|
||||
|
||||
glTranslated(8 * scale, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
float Engine::GetScale() const {
|
||||
float widthRatio = Width() / BASE_WIDTH;
|
||||
float heightRatio = Height() / BASE_HEIGHT;
|
||||
|
||||
return (widthRatio + heightRatio) / 2.0f;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -238,7 +484,7 @@ void Engine::Render(float elapsedTime) {
|
||||
m_bullets[0] = new Bullet(m_player);
|
||||
}
|
||||
bulletTime = .1f;
|
||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", m_player.GetPOV(), m_player.GetDirection() * 10, .5f);
|
||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "windowsaccount.wav", m_player.GetPOV(), m_player.GetDirection() * 10, .5f);
|
||||
if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
|
||||
glClearColor(.8f, .8f, .8f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
@@ -261,11 +507,8 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
if (m_isSkybox) m_skybox.Render(skybox);
|
||||
|
||||
if (m_wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
ProcessNotificationQueue();
|
||||
DrawHud(elapsedTime, bloc);
|
||||
if (m_wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
static bool fell = false;
|
||||
if (m_player.GetPosition().y < 1.7f && !fell) {
|
||||
@@ -280,54 +523,65 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
void Engine::KeyPressEvent(unsigned char key) {
|
||||
switch (key) {
|
||||
case 36: // ESC
|
||||
Stop();
|
||||
break;
|
||||
case 94: // F10
|
||||
SetFullscreen(!IsFullscreen());
|
||||
break;
|
||||
case 22: // W
|
||||
if (!m_keyW) {
|
||||
// std::cout << "W " << std::endl;
|
||||
m_keyW = true;
|
||||
}
|
||||
break;
|
||||
case 0: // A
|
||||
case 0: // A - Gauche
|
||||
if (!m_keyA) {
|
||||
//std::cout << "A " << std::endl;
|
||||
m_keyA = true;
|
||||
}
|
||||
break;
|
||||
case 18: // S
|
||||
if (!m_keyS) {
|
||||
//std::cout << "S " << std::endl;
|
||||
m_keyS = true;
|
||||
}
|
||||
break;
|
||||
case 3: // D
|
||||
case 3: // D - Droite
|
||||
if (!m_keyD) {
|
||||
//std::cout << "D " << std::endl;
|
||||
m_keyD = true;
|
||||
}
|
||||
break;
|
||||
case 38: // Left Shift
|
||||
if (!m_keylshift) {
|
||||
//std::cout << "Dash!" << std::endl;
|
||||
m_keylshift = true;
|
||||
case 18: // S - Reculer
|
||||
if (!m_keyS) {
|
||||
m_keyS = true;
|
||||
}
|
||||
break;
|
||||
case 57: // Space
|
||||
case 22: // W - Avancer
|
||||
if (!m_keyW) {
|
||||
m_keyW = true;
|
||||
}
|
||||
break;
|
||||
case 36: // ESC - Quitter
|
||||
Stop();
|
||||
break;
|
||||
case 57: // Space - Sauter
|
||||
if (!m_keySpace) {
|
||||
//std::cout << "Jump! " << std::endl;
|
||||
m_keySpace = true;
|
||||
}
|
||||
break;
|
||||
case 94: // F10 - Plein <20>cran
|
||||
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
||||
//SetFullscreen(!IsFullscreen());
|
||||
break;
|
||||
case 2: // C - Ignorer
|
||||
break;
|
||||
case 5: // F - Ignorer
|
||||
case 24: // Y - Ignorer
|
||||
case 255: // Fn - 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
|
||||
break;
|
||||
case 8: // I - Ignorer
|
||||
break;
|
||||
case 17: // R - Ignorer
|
||||
break;
|
||||
case 19: // T - Ignorer
|
||||
break;
|
||||
case 24: // Y - Ignorer
|
||||
break;
|
||||
case 255: // Fn - Ignorer
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unhandled key: " << (int)key << std::endl;
|
||||
}
|
||||
@@ -335,44 +589,61 @@ void Engine::KeyPressEvent(unsigned char key) {
|
||||
|
||||
void Engine::KeyReleaseEvent(unsigned char key) {
|
||||
switch (key) {
|
||||
case 5:
|
||||
case 0: // A - Stop gauche
|
||||
m_keyA = false;
|
||||
break;
|
||||
case 2: // C - Toggle crosshair
|
||||
m_displayCrosshair = !m_displayCrosshair;
|
||||
std::cout << "DISPLAY CROSSHAIR " << (m_displayCrosshair ? "enabled" : "disabled") << std::endl;
|
||||
break;
|
||||
case 3: // D - Stop droite
|
||||
m_keyD = false;
|
||||
break;
|
||||
case 5: // F - Toggle flash
|
||||
m_flash = !m_flash;
|
||||
break;
|
||||
case 12:
|
||||
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;
|
||||
break;
|
||||
case 8: // I - Toggle render data
|
||||
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;
|
||||
case 17:
|
||||
case 17: // R - Toggle skybox
|
||||
m_isSkybox = !m_isSkybox;
|
||||
break;
|
||||
case 24: // Y
|
||||
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;
|
||||
case 24: // Y - Wireframe
|
||||
m_wireframe = !m_wireframe;
|
||||
if (m_wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
else
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
break;
|
||||
case 22: // W
|
||||
//std::cout << "rW " << std::endl;
|
||||
m_keyW = false;
|
||||
break;
|
||||
case 0: // A
|
||||
//std::cout << "rA " << std::endl;
|
||||
m_keyA = false;
|
||||
break;
|
||||
case 18: // S
|
||||
//std::cout << "rS " << std::endl;
|
||||
m_keyS = false;
|
||||
break;
|
||||
case 3: // D
|
||||
//std::cout << "rD " << std::endl;
|
||||
m_keyD = false;
|
||||
break;
|
||||
case 38: // Left Shift
|
||||
//std::cout << "rLS " << std::endl;
|
||||
m_keylshift = false;
|
||||
break;
|
||||
case 57: // Espace
|
||||
//std::cout << "rSpace " << std::endl;
|
||||
case 57: // Espace - Stop sauter
|
||||
m_keySpace = false;
|
||||
break;
|
||||
}
|
||||
@@ -437,10 +708,9 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool stopOnError) {
|
||||
texture.Load(filename);
|
||||
if (!texture.IsValid())
|
||||
{
|
||||
bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError) {
|
||||
texture.Load(filename, useMipmaps);
|
||||
if (!texture.IsValid()) {
|
||||
std::cerr << "Unable to load texture (" << filename << ")" << std::endl;
|
||||
if (stopOnError)
|
||||
Stop();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#ifndef ENGINE_H__
|
||||
#define ENGINE_H__
|
||||
|
||||
#include "define.h"
|
||||
#include "openglcontext.h"
|
||||
#include "texture.h"
|
||||
@@ -31,15 +32,23 @@ public:
|
||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
||||
|
||||
private:
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool stopOnError = true);
|
||||
void DrawHud(float elapsedTime, BlockType bloc);
|
||||
void PrintText(unsigned int x, unsigned int y, const std::string& t);
|
||||
float GetScale() const;
|
||||
|
||||
int GetFps(float elapsedTime) const;
|
||||
int GetCountdown(float elapsedTime);
|
||||
|
||||
bool m_wireframe = false;
|
||||
bool m_isSkybox = true;
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||
|
||||
int m_renderCount = 0;
|
||||
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 DisplayInfo(float elapsedTime, BlockType bloc);
|
||||
void DrawHud(float elapsedTime, BlockType bloc);
|
||||
void PrintText(float x, float y, float scale, const std::string& t);
|
||||
|
||||
Shader m_shader01;
|
||||
BlockInfo* m_blockinfo[BTYPE_LAST];
|
||||
@@ -50,9 +59,10 @@ private:
|
||||
Texture m_textureSkybox;
|
||||
Texture m_textureFont;
|
||||
Texture m_textureCrosshair;
|
||||
Texture m_textureGun;
|
||||
|
||||
Skybox m_skybox;
|
||||
Audio m_audio = Audio(AUDIO_PATH "music01.wav");
|
||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||
|
||||
irrklang::ISound* m_powpow;
|
||||
irrklang::ISound* m_scream;
|
||||
@@ -61,11 +71,28 @@ 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;
|
||||
bool m_block = false;
|
||||
bool m_flash = true;
|
||||
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;
|
||||
bool m_keyD = false;
|
||||
bool m_keylshift = false;
|
||||
bool m_keySpace = false;
|
||||
bool m_mouseL = false;
|
||||
bool m_mouseR = false;
|
||||
@@ -73,9 +100,7 @@ private:
|
||||
bool m_mouseWU = false;
|
||||
bool m_mouseWD = false;
|
||||
|
||||
bool m_block = false;
|
||||
bool m_flash = true;
|
||||
std::string m_messageNotification = "";
|
||||
};
|
||||
|
||||
|
||||
#endif // ENGINE_H__
|
||||
|
@@ -5,5 +5,5 @@
|
||||
int main() {
|
||||
Engine engine;
|
||||
engine.SetMaxFps(60);
|
||||
engine.Start("Syndicat Quebecois de la Construction Simulator 2023", 640, 480, false);
|
||||
engine.Start("Syndicat Quebecois de la Construction Simulator 2023", BASE_WIDTH, BASE_HEIGHT, false);
|
||||
}
|
||||
|
BIN
SQCSim2021/media/audio/notify.wav
Normal file
BIN
SQCSim2021/media/audio/start.wav
Normal file
BIN
SQCSim2021/media/audio/windowsaccount.wav
Normal file
After Width: | Height: | Size: 262 KiB |
After Width: | Height: | Size: 261 KiB |
After Width: | Height: | Size: 363 KiB |
After Width: | Height: | Size: 363 KiB |
After Width: | Height: | Size: 249 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 370 KiB |
After Width: | Height: | Size: 370 KiB |
After Width: | Height: | Size: 249 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 254 KiB |
After Width: | Height: | Size: 255 KiB |
After Width: | Height: | Size: 270 KiB |
After Width: | Height: | Size: 269 KiB |
After Width: | Height: | Size: 310 KiB |
After Width: | Height: | Size: 310 KiB |
After Width: | Height: | Size: 359 KiB |
After Width: | Height: | Size: 360 KiB |
After Width: | Height: | Size: 367 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 327 KiB |
After Width: | Height: | Size: 348 KiB |
After Width: | Height: | Size: 382 KiB |
After Width: | Height: | Size: 327 KiB |
After Width: | Height: | Size: 329 KiB |
After Width: | Height: | Size: 362 KiB |
After Width: | Height: | Size: 641 KiB |
After Width: | Height: | Size: 654 KiB |
After Width: | Height: | Size: 651 KiB |
After Width: | Height: | Size: 640 KiB |
After Width: | Height: | Size: 654 KiB |
After Width: | Height: | Size: 650 KiB |
After Width: | Height: | Size: 474 KiB |
After Width: | Height: | Size: 501 KiB |
After Width: | Height: | Size: 563 KiB |
After Width: | Height: | Size: 473 KiB |
After Width: | Height: | Size: 500 KiB |
After Width: | Height: | Size: 563 KiB |
After Width: | Height: | Size: 698 KiB |
After Width: | Height: | Size: 719 KiB |
After Width: | Height: | Size: 735 KiB |
After Width: | Height: | Size: 698 KiB |
After Width: | Height: | Size: 719 KiB |
After Width: | Height: | Size: 735 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 783 KiB |
After Width: | Height: | Size: 804 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 783 KiB |
After Width: | Height: | Size: 804 KiB |
After Width: | Height: | Size: 276 KiB |
After Width: | Height: | Size: 276 KiB |
After Width: | Height: | Size: 315 KiB |
After Width: | Height: | Size: 315 KiB |
After Width: | Height: | Size: 338 KiB |
After Width: | Height: | Size: 395 KiB |
After Width: | Height: | Size: 395 KiB |
After Width: | Height: | Size: 338 KiB |
After Width: | Height: | Size: 258 KiB |
After Width: | Height: | Size: 258 KiB |
After Width: | Height: | Size: 655 KiB |
After Width: | Height: | Size: 658 KiB |
After Width: | Height: | Size: 679 KiB |
After Width: | Height: | Size: 654 KiB |
After Width: | Height: | Size: 657 KiB |
After Width: | Height: | Size: 678 KiB |
After Width: | Height: | Size: 473 KiB |
After Width: | Height: | Size: 481 KiB |
After Width: | Height: | Size: 504 KiB |
After Width: | Height: | Size: 474 KiB |
After Width: | Height: | Size: 481 KiB |
After Width: | Height: | Size: 505 KiB |
After Width: | Height: | Size: 688 KiB |
After Width: | Height: | Size: 701 KiB |
After Width: | Height: | Size: 715 KiB |
After Width: | Height: | Size: 843 KiB |
After Width: | Height: | Size: 874 KiB |
After Width: | Height: | Size: 891 KiB |
After Width: | Height: | Size: 842 KiB |
After Width: | Height: | Size: 874 KiB |
After Width: | Height: | Size: 891 KiB |
After Width: | Height: | Size: 688 KiB |
After Width: | Height: | Size: 701 KiB |
After Width: | Height: | Size: 715 KiB |
After Width: | Height: | Size: 397 KiB |
After Width: | Height: | Size: 390 KiB |
After Width: | Height: | Size: 400 KiB |
After Width: | Height: | Size: 398 KiB |
After Width: | Height: | Size: 389 KiB |
After Width: | Height: | Size: 400 KiB |
After Width: | Height: | Size: 244 KiB |