Compare commits
17 Commits
sqc_51-fin
...
SQC-09
Author | SHA1 | Date | |
---|---|---|---|
|
a054a7bff1 | ||
|
b712c950c6 | ||
|
3f774d7c2e | ||
|
6668127f15 | ||
|
54c25e6f78 | ||
|
bf164af23b | ||
|
0d948e3a28 | ||
|
b97890fff3 | ||
|
432b8545a7 | ||
|
54e2f32aba | ||
|
90fdc8ed1b | ||
|
47906776c8 | ||
|
fa9f0a3a8a | ||
|
43f3ce1428 | ||
|
bfda5e8948 | ||
|
aacb3b4ceb | ||
|
2532dfb258 |
@@ -5,7 +5,7 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
|
||||
m_velocity = Vector3f(0, 0, 0);
|
||||
m_airborne = true;
|
||||
m_hp = 0.75f; //TODO: Remettre <20> 1.0f
|
||||
m_username = "Zelda Bee-Bop";
|
||||
m_username = "Zelda Bee-Bop56";
|
||||
}
|
||||
|
||||
void Player::TurnLeftRight(float value) {
|
||||
|
@@ -27,5 +27,6 @@
|
||||
#define SHADER_PATH "./media/shaders/"
|
||||
#define AUDIO_PATH "./media/audio/"
|
||||
#define CHUNK_PATH "./media/chunks/"
|
||||
#define MENU_ITEM_PATH "./media/menu_items/"
|
||||
|
||||
#endif // DEFINE_H__
|
||||
|
@@ -1,5 +1,23 @@
|
||||
#include "engine.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() {
|
||||
@@ -10,6 +28,200 @@ Engine::~Engine() {
|
||||
m_world.GetChunks().Get(x, y)->~Chunk();
|
||||
}
|
||||
|
||||
void Engine::DrawMenu()
|
||||
{
|
||||
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();
|
||||
|
||||
MenuBGTexture.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();
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if (m_gamestate != GameState::OPTIONS)
|
||||
{
|
||||
MenuTitleTexture.Bind();
|
||||
glTranslated(200, 300, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 200);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sTitle, 200);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sTitle, 300);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 300);
|
||||
glEnd();
|
||||
|
||||
MenuStartTexture.Bind();
|
||||
glTranslated(80, -225, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 100);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 100);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
/*MenuResumeTexture.Bind();
|
||||
glTranslated(0, -100, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();*/
|
||||
|
||||
/*MenuOptionsTexture.Bind();
|
||||
glTranslated(0, -100, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();*/
|
||||
|
||||
MenuQuitTexture.Bind();
|
||||
glTranslated(0, -100, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 100);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 100);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*MenuOptionsTexture.Bind();
|
||||
glTranslated(200, 0, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sTitle, 0);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sTitle, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
WireFrameTexture.Bind();
|
||||
glTranslated(0, 300, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
OnOffBtnTexture.Bind();
|
||||
glTranslated(200, 0, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
glTranslated(-400, -300, 0);
|
||||
|
||||
MusicTexture.Bind();
|
||||
glTranslated(200, 200, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
OnOffBtnTexture.Bind();
|
||||
glTranslated(200, 0, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 125);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 125);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
BackBtnTexture.Bind();
|
||||
glTranslated(-375, 175, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 140);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(sButton, 140);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(sButton, 200);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, 200);
|
||||
glEnd();*/
|
||||
}
|
||||
|
||||
//glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
ShowCursor();
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
GLenum glewErr = glewInit();
|
||||
if (glewErr != GLEW_OK) {
|
||||
@@ -35,6 +247,7 @@ void Engine::Init() {
|
||||
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);
|
||||
@@ -47,18 +260,18 @@ void Engine::Init() {
|
||||
m_bullets[x] = nullptr;
|
||||
|
||||
uint64_t seed = SEED;
|
||||
std::string playname = "La Chienne <20> Jacques";
|
||||
if (NETWORK_TEST) { // Test connexion r<>seau.
|
||||
std::string playname = "La Chienne <20> Jacques";
|
||||
if (NETWORK_TEST) { // Test connexion r<>seau.
|
||||
if (!m_conn.Init()) {
|
||||
if (!m_conn.Connect(SRV_ADDR, playname)) {
|
||||
// setup jeu en r<>seau.
|
||||
std::cout << "ID re<72>u du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
||||
std::cout << "Seed re<72>u du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
||||
// setup jeu en r<>seau.
|
||||
std::cout << "ID re<72>u du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
||||
std::cout << "Seed re<72>u du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
||||
seed = m_conn.getSeed();
|
||||
}
|
||||
else std::cout << "Erreur de connexion." << std::endl;
|
||||
}
|
||||
else std::cout << "Erreur de cr<63>ation de socket." << std::endl;
|
||||
else std::cout << "Erreur de cr<63>ation de socket." << std::endl;
|
||||
}
|
||||
|
||||
m_world.SetSeed(seed);
|
||||
@@ -77,8 +290,13 @@ void Engine::LoadResource() {
|
||||
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);
|
||||
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", true);
|
||||
|
||||
LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png");
|
||||
LoadTexture(MenuBGTexture, MENU_ITEM_PATH "test.png");
|
||||
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
||||
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
||||
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
||||
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");
|
||||
@@ -113,6 +331,89 @@ 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();
|
||||
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;
|
||||
@@ -133,6 +434,7 @@ void Engine::DisplayCrosshair() {
|
||||
void Engine::DisplayCurrentItem() {
|
||||
}
|
||||
|
||||
|
||||
void Engine::DisplayHud(int timer) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glLoadIdentity();
|
||||
@@ -146,7 +448,7 @@ void Engine::DisplayHud(int timer) {
|
||||
float playerHp = m_player.GetHP();
|
||||
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
||||
|
||||
// Arri<72>re-plan (Barre HP)
|
||||
// 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
|
||||
@@ -155,7 +457,7 @@ void Engine::DisplayHud(int timer) {
|
||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||
glEnd();
|
||||
|
||||
//TODO: Associer avec m<>chanique de vie du joueur
|
||||
//TODO: Associer avec m<>chanique de vie du joueur
|
||||
|
||||
// Barre HP
|
||||
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
||||
@@ -166,7 +468,7 @@ void Engine::DisplayHud(int timer) {
|
||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||
glEnd();
|
||||
|
||||
// Barre <20>quip
|
||||
// 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);
|
||||
@@ -187,7 +489,7 @@ void Engine::DisplayHud(int timer) {
|
||||
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
//glDisable(GL_BLEND);
|
||||
|
||||
// Username
|
||||
glEnable(GL_BLEND);
|
||||
@@ -224,7 +526,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
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
|
||||
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();
|
||||
@@ -249,6 +551,7 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
@@ -261,6 +564,17 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -329,6 +643,13 @@ int Engine::GetCountdown(float elapsedTime) {
|
||||
}
|
||||
|
||||
void Engine::Render(float elapsedTime) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
if (m_gamestate == GameState::PLAY)
|
||||
{
|
||||
HideCursor();
|
||||
CenterMouse(); //D<>placement de centermouse dans l'action de jouer
|
||||
|
||||
//static float gameTime = elapsedTime;
|
||||
static irrklang::ISound* step; // Pour les sons de pas.
|
||||
static float pollTime = 0;
|
||||
@@ -343,7 +664,6 @@ void Engine::Render(float elapsedTime) {
|
||||
Transformation all;
|
||||
Transformation skybox;
|
||||
Vector3f vstep;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
// Transformations initiales
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -368,8 +688,8 @@ void Engine::Render(float elapsedTime) {
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
|
||||
// son vecteur de v<>locit<69> (pour l'effet Doppler)
|
||||
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
|
||||
// son vecteur de v<>locit<69> (pour l'effet Doppler)
|
||||
pollTime = 0;
|
||||
}
|
||||
|
||||
@@ -381,7 +701,7 @@ void Engine::Render(float elapsedTime) {
|
||||
if (m_mouseWU) bloc++;
|
||||
else if (m_mouseWD) bloc--;
|
||||
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
|
||||
else if (bloc == BTYPE_AIR) bloc = BTYPE_LAST; // La selection de BTYPE_LAST <20>quipe l'arme.
|
||||
else if (bloc == BTYPE_AIR) bloc = BTYPE_LAST; // La selection de BTYPE_LAST <20>quipe l'arme.
|
||||
m_mouseWU = m_mouseWD = false;
|
||||
|
||||
if (m_mouseL) {
|
||||
@@ -393,7 +713,7 @@ void Engine::Render(float elapsedTime) {
|
||||
m_bullets[x] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
||||
break;
|
||||
}
|
||||
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
|
||||
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
|
||||
m_bullets[0]->~Bullet();
|
||||
m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
||||
}
|
||||
@@ -423,6 +743,7 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
if (m_isSkybox) m_skybox.Render(skybox);
|
||||
|
||||
ProcessNotificationQueue();
|
||||
DrawHud(elapsedTime, bloc);
|
||||
|
||||
static bool fell = false;
|
||||
@@ -434,6 +755,13 @@ void Engine::Render(float elapsedTime) {
|
||||
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
|
||||
fell = false;
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
||||
{
|
||||
DrawMenu();
|
||||
}
|
||||
else if (m_gamestate == GameState::QUIT)
|
||||
Stop();
|
||||
}
|
||||
|
||||
void Engine::KeyPressEvent(unsigned char key) {
|
||||
@@ -459,14 +787,15 @@ void Engine::KeyPressEvent(unsigned char key) {
|
||||
}
|
||||
break;
|
||||
case 36: // ESC - Quitter
|
||||
Stop();
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
//Stop();
|
||||
break;
|
||||
case 57: // Space - Sauter
|
||||
if (!m_keySpace) {
|
||||
m_keySpace = true;
|
||||
}
|
||||
break;
|
||||
case 94: // F10 - Plein <20>cran
|
||||
case 94: // F10 - Plein <20>cran
|
||||
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
||||
//SetFullscreen(!IsFullscreen());
|
||||
break;
|
||||
@@ -474,6 +803,13 @@ 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
|
||||
@@ -522,6 +858,12 @@ 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;
|
||||
@@ -555,18 +897,22 @@ void Engine::MouseMoveEvent(int x, int y) {
|
||||
m_player.TurnLeftRight(x - (Width() / 2));
|
||||
m_player.TurnTopBottom(y - (Height() / 2));
|
||||
|
||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
||||
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
|
||||
// MouseMoveEvent, etc
|
||||
if (x == (Width() / 2) && y == (Height() / 2))
|
||||
return;
|
||||
|
||||
CenterMouse();
|
||||
}
|
||||
|
||||
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
m_mousemx = x;
|
||||
m_mousemy = y;
|
||||
|
||||
if (m_gamestate == GameState::PLAY)
|
||||
{
|
||||
switch (button) {
|
||||
case MOUSE_BUTTON_LEFT:
|
||||
m_mouseL = true;
|
||||
@@ -585,6 +931,14 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
break;
|
||||
case MOUSE_BUTTON_NONE: break;
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::MAIN_MENU)
|
||||
{
|
||||
if ((m_mousemx >= 285 && m_mousemx <= 490) && (m_mousemy >= 150 && m_mousemy <= 250))
|
||||
m_gamestate = GameState::PLAY;
|
||||
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 300 && m_mousemy <= 400))
|
||||
m_gamestate = GameState::QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
|
@@ -24,6 +24,7 @@ class Engine : public OpenglContext {
|
||||
public:
|
||||
Engine();
|
||||
virtual ~Engine();
|
||||
virtual void DrawMenu();
|
||||
virtual void Init();
|
||||
virtual void DeInit();
|
||||
virtual void LoadResource();
|
||||
@@ -43,6 +44,10 @@ private:
|
||||
|
||||
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);
|
||||
@@ -73,6 +78,15 @@ private:
|
||||
|
||||
Bullet* m_bullets[MAX_BULLETS];
|
||||
|
||||
//Menu
|
||||
enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
||||
GameState m_gamestate = GameState::MAIN_MENU;
|
||||
Texture MenuTitleTexture;
|
||||
Texture MenuBGTexture;
|
||||
Texture MenuStartTexture;
|
||||
Texture MenuQuitTexture;
|
||||
Texture MenuOptionsTexture;
|
||||
|
||||
float m_scale;
|
||||
float m_time = 0;
|
||||
|
||||
@@ -89,6 +103,8 @@ private:
|
||||
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,6 +115,11 @@ private:
|
||||
bool m_mouseC = false;
|
||||
bool m_mouseWU = false;
|
||||
bool m_mouseWD = false;
|
||||
//Pour trouver ou est la souris
|
||||
float m_mousemx = 0;
|
||||
float m_mousemy = 0;
|
||||
|
||||
std::string m_messageNotification = "";
|
||||
};
|
||||
|
||||
#endif // ENGINE_H__
|
||||
|
BIN
SQCSim2021/media/menu_items/BasicPlay.png
Normal file
BIN
SQCSim2021/media/menu_items/BasicPlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
SQCSim2021/media/menu_items/BasicQuit.png
Normal file
BIN
SQCSim2021/media/menu_items/BasicQuit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
SQCSim2021/media/menu_items/test.png
Normal file
BIN
SQCSim2021/media/menu_items/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 KiB |
BIN
SQCSim2021/media/textures/Bouton/BasicPlay.png
Normal file
BIN
SQCSim2021/media/textures/Bouton/BasicPlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
BIN
SQCSim2021/media/textures/Bouton/BasicQuit.png
Normal file
BIN
SQCSim2021/media/textures/Bouton/BasicQuit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
SQCSim2021/media/textures/GUN.png
Normal file
BIN
SQCSim2021/media/textures/GUN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 267 KiB |
Reference in New Issue
Block a user