Merge branch 'master' into sqc7_server

This commit is contained in:
Frederic Leger 2023-09-25 15:44:22 -04:00 committed by GitHub
commit e685396589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
103 changed files with 41 additions and 3 deletions

View File

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

View File

@ -120,7 +120,7 @@ void Engine::DisplayCrosshair() {
void Engine::DisplayCurrentItem() { void Engine::DisplayCurrentItem() {
} }
void Engine::DisplayHud() { void Engine::DisplayHud(int timer) {
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glLoadIdentity(); glLoadIdentity();
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -186,6 +186,13 @@ void Engine::DisplayHud() {
std::ostringstream ss; std::ostringstream ss;
ss << m_player.GetUsername(); ss << m_player.GetUsername();
PrintText(fPosX, fPosY, scale, ss.str()); 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) { void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
@ -240,13 +247,14 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
int timer = GetCountdown(elapsedTime);
if (m_displayInfo) { if (m_displayInfo) {
DisplayInfo(elapsedTime, bloc); DisplayInfo(elapsedTime, bloc);
} }
if (m_displayHud) { if (m_displayHud) {
DisplayHud(); DisplayHud(timer);
} }
if (m_displayCrosshair) { if (m_displayCrosshair) {
@ -295,6 +303,18 @@ float Engine::GetScale() const {
} }
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; } 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) { void Engine::Render(float elapsedTime) {
//static float gameTime = elapsedTime; //static float gameTime = elapsedTime;
@ -424,6 +444,8 @@ void Engine::KeyPressEvent(unsigned char key) {
break; break;
case 5: // F - Ignorer case 5: // F - Ignorer
break; break;
case 6: // G - Ignorer
break;
case 12: // M - Ignorer case 12: // M - Ignorer
break; break;
case 7: // H - Ignorer case 7: // H - Ignorer
@ -432,6 +454,8 @@ void Engine::KeyPressEvent(unsigned char key) {
break; break;
case 17: // R - Ignorer case 17: // R - Ignorer
break; break;
case 19: // T - Ignorer
break;
case 24: // Y - Ignorer case 24: // Y - Ignorer
break; break;
case 255: // Fn - Ignorer case 255: // Fn - Ignorer
@ -456,6 +480,10 @@ void Engine::KeyReleaseEvent(unsigned char key) {
case 5: // F - Toggle flash case 5: // F - Toggle flash
m_flash = !m_flash; m_flash = !m_flash;
break; 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 case 7: // H - Toggle HUD
m_displayHud = !m_displayHud; m_displayHud = !m_displayHud;
std::cout << "DISPLAY HUD " << (m_displayHud ? "enabled" : "disabled") << std::endl; std::cout << "DISPLAY HUD " << (m_displayHud ? "enabled" : "disabled") << std::endl;
@ -473,6 +501,10 @@ void Engine::KeyReleaseEvent(unsigned char key) {
case 18: // S - Stop reculer case 18: // S - Stop reculer
m_keyS = false; m_keyS = false;
break; break;
case 19: // T -Reset countdown
m_resetcountdown = true;
std::cout << "RESET COUNTDOWN" << std::endl;
break;
case 22: // W - Stop avancer case 22: // W - Stop avancer
m_keyW = false; m_keyW = false;
break; break;

View File

@ -35,12 +35,13 @@ private:
float GetScale() const; float GetScale() const;
int GetFps(float elapsedTime) const; int GetFps(float elapsedTime) const;
int GetCountdown(float elapsedTime);
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
void DisplayCrosshair(); void DisplayCrosshair();
void DisplayCurrentItem(); void DisplayCurrentItem();
void DisplayHud(); void DisplayHud(int timer);
void DisplayInfo(float elapsedTime, BlockType bloc); void DisplayInfo(float elapsedTime, BlockType bloc);
void DrawHud(float elapsedTime, BlockType bloc); void DrawHud(float elapsedTime, BlockType bloc);
void PrintText(float x, float y, float scale, const std::string& t); void PrintText(float x, float y, float scale, const std::string& t);
@ -67,8 +68,10 @@ private:
Bullet* m_bullets[MAX_BULLETS]; Bullet* m_bullets[MAX_BULLETS];
float m_scale; float m_scale;
float m_time = 0;
int m_renderCount = 0; int m_renderCount = 0;
int m_countdown = COUNTDOWN;
bool m_wireframe = false; bool m_wireframe = false;
bool m_isSkybox = true; bool m_isSkybox = true;
@ -77,6 +80,8 @@ private:
bool m_displayCrosshair = true; bool m_displayCrosshair = true;
bool m_displayHud = true; bool m_displayHud = true;
bool m_displayInfo = false; bool m_displayInfo = false;
bool m_resetcountdown = false;
bool m_stopcountdown = false;
bool m_keyW = false; bool m_keyW = false;
bool m_keyA = false; bool m_keyA = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Some files were not shown because too many files have changed in this diff Show More