Merge branch 'master' into sqc_13_connexion_srv

This commit is contained in:
MarcEricMartel 2023-09-25 16:30:49 -04:00
commit 3ff2634e51
8 changed files with 41 additions and 3 deletions

View File

@ -5,6 +5,7 @@
#include <SFML/Graphics.hpp>
#include <iostream>
#include <chrono>
#include <iomanip>
#ifdef _WIN32
#include <windows.h>

View File

@ -138,7 +138,7 @@ void Engine::DisplayCrosshair() {
void Engine::DisplayCurrentItem() {
}
void Engine::DisplayHud() {
void Engine::DisplayHud(int timer) {
glBindTexture(GL_TEXTURE_2D, 0);
glLoadIdentity();
glDisable(GL_BLEND);
@ -204,6 +204,13 @@ void Engine::DisplayHud() {
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) {
@ -258,13 +265,14 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
int timer = GetCountdown(elapsedTime);
if (m_displayInfo) {
DisplayInfo(elapsedTime, bloc);
}
if (m_displayHud) {
DisplayHud();
DisplayHud(timer);
}
if (m_displayCrosshair) {
@ -313,6 +321,18 @@ 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;
@ -442,6 +462,8 @@ void Engine::KeyPressEvent(unsigned char key) {
break;
case 5: // F - Ignorer
break;
case 6: // G - Ignorer
break;
case 12: // M - Ignorer
break;
case 7: // H - Ignorer
@ -450,6 +472,8 @@ 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
@ -474,6 +498,10 @@ 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;
@ -491,6 +519,10 @@ 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;

View File

@ -38,12 +38,13 @@ 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 DisplayCrosshair();
void DisplayCurrentItem();
void DisplayHud();
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);
@ -71,8 +72,10 @@ 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;
@ -81,6 +84,8 @@ private:
bool m_displayCrosshair = true;
bool m_displayHud = true;
bool m_displayInfo = false;
bool m_resetcountdown = false;
bool m_stopcountdown = false;
bool m_keyW = false;
bool m_keyA = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB