refactor: réorganisation du code et des fichiers

- Déplacement des fichiers `networking.cpp`, `networking.h`, `networking_client.h` vers le répertoire `Network`
- Mise à jour des inclusions de fichiers pour refléter les nouveaux chemins
- Ajout des nouvelles fonctions `handleQuitThread`, `handleQuit`, `cleanup` dans `close.cpp`
- Mise à jour de `CMakeLists.txt` pour inclure les nouveaux chemins des fichiers
- Mise à jour de `main.cpp` pour inclure les nouveaux chemins des fichiers
- Ajout de la gestion des threads pour les poissons, les joueurs et le requin
- Ajout de la gestion des événements de menu et de la musique de fond
This commit is contained in:
2024-12-18 14:01:41 +01:00
parent 1845c2f1c9
commit dec3ab3aff
15 changed files with 18 additions and 19 deletions

View File

@@ -3,6 +3,7 @@
//
#include "networking.h"
std::unordered_map<int, std::pair<int, int>> playerPositions;
std::unordered_map<int, std::chrono::time_point<std::chrono::steady_clock>> lastKeepAlive;

View File

@@ -7,7 +7,7 @@
#include <thread>
#include <unordered_map>
#include <chrono>
#include "../env.h"
#include "../Utility/env.h"
#include "networking_client.h"
#include "../player.h"
#include "../shark.h"

View File

@@ -9,7 +9,7 @@
#include <sstream>
#include <thread>
#include <chrono>
#include "../env.h"
#include "../Utility/env.h"
#include "../player.h"
class Player;

View File

@@ -12,7 +12,7 @@
#include <thread>
#include <mutex>
#include "env.h"
#include "../network/networking.h"
#include "../Network/networking.h"
void cleanup();
void handleQuit();

View File

@@ -9,7 +9,7 @@
#include <vector>
#include <cmath>
#include <string>
#include "player.h"
#include "../player.h"
double calculateDistance(int x1, int y1, int x2, int y2);
void displayNearbyPlayers(SDL_Renderer* renderer, TTF_Font* font, Player& currentPlayer, std::vector<Player>& players, double threshold);

View File

@@ -3,9 +3,6 @@
//
#include "decors.h"
#include <iostream>
#include "env.h"
void Rock::draw(SDL_Renderer* renderer) const{
Camera& camera = Camera::getInstance();

View File

@@ -9,7 +9,9 @@
#include <ctime>
#include <cstdlib>
#include <vector>
#include <iostream>
#include "camera.h"
#include "Utility/env.h"
class Rock {
public:

2
fish.h
View File

@@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include "camera.h"
#include "env.h"
#include "Utility/env.h"
class Fish {
private:

View File

@@ -21,11 +21,12 @@
#include "Utility/utility.h"
#include "player.h"
#include "menu.h"
#include "network/networking.h"
#include "network/networking_client.h"
#include "Network/networking.h"
#include "Network/networking_client.h"
#include "shark.h"
#include "Utility/event.h"
#include "Utility/close.h"
#include "event.h"
#include <system_error>

2
menu.h
View File

@@ -1,5 +1,5 @@
#include <iostream>
#include "env.h"
#include "Utility/env.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>

View File

@@ -1,10 +1,5 @@
#include "player.h"
#include <syncstream>
#include <tuple>
#include "network/networking_client.h"
#include "camera.h"
void Player::updatePlayerPos(int x, int y) {
this->x = x;
this->y = y;

View File

@@ -6,6 +6,10 @@
#include <iostream>
#include <tuple>
#include <vector>
#include <syncstream>
#include <tuple>
#include "Network/networking_client.h"
#include "camera.h"
#include "fish.h"

View File

@@ -5,8 +5,6 @@
#define sharkIMG "../img/shark.png"
#include "shark.h"
#include "network/networking.h"
Shark::Shark(const int x, const int y, const float vx, const float vy, const int id, const int width, const int height, SDL_Renderer* renderer, std::vector<Player> &players_list)
: x(x), y(y), vx(vx), vy(vy), id(id), width(width), height(height), players_list(players_list) {
SDL_Surface* sharkSurface = IMG_Load(sharkIMG);

View File

@@ -10,6 +10,7 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <chrono>
#include "Network/networking.h"
class Shark {
private: