Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/implement-the-te…
Browse files Browse the repository at this point in the history
…sts_run-rule-in-makefile-of-ai
  • Loading branch information
theophile-jr committed Jun 13, 2024
2 parents e6b62ce + 12f3015 commit a4ada7c
Show file tree
Hide file tree
Showing 44 changed files with 903 additions and 66 deletions.
4 changes: 3 additions & 1 deletion gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SRC = src/Error/Error.cpp \
\
src/Render/Render.cpp \
src/Render/UserCamera.cpp \
src/Render/Decoration.cpp \
\
src/Event/Event.cpp \
\
Expand All @@ -40,7 +41,8 @@ TEST_FILES = Network/TestNetwork.cpp \
GameDatas/TestGameData.cpp \
GameDatas/TestEgg.cpp \
GameDatas/TestTeam.cpp \
Render/TestCamera.cpp \
Render/TestUserCamera.cpp \
Render/TestDecoration.cpp \
GUIUpdater/TestGUIUpdater.cpp \
Event/TestEvent.cpp \

Expand Down
Binary file added gui/assets/decoration/lantern.glb
Binary file not shown.
Binary file added gui/assets/decoration/tree.glb
Binary file not shown.
Binary file removed gui/assets/deraumere.glb
Binary file not shown.
Binary file removed gui/assets/egg.glb
Binary file not shown.
Binary file removed gui/assets/food.glb
Binary file not shown.
Binary file removed gui/assets/linemate.glb
Binary file not shown.
Binary file removed gui/assets/mendiane.glb
Binary file not shown.
Binary file removed gui/assets/phiras.glb
Binary file not shown.
Binary file added gui/assets/player/egg.glb
Binary file not shown.
File renamed without changes.
Binary file added gui/assets/resources/deraumere.glb
Binary file not shown.
Binary file added gui/assets/resources/food.glb
Binary file not shown.
Binary file added gui/assets/resources/linemate.glb
Binary file not shown.
Binary file added gui/assets/resources/mendiane.glb
Binary file not shown.
Binary file added gui/assets/resources/phiras.glb
Binary file not shown.
Binary file added gui/assets/resources/sibur.glb
Binary file not shown.
Binary file added gui/assets/resources/thystame.glb
Binary file not shown.
Binary file removed gui/assets/sibur.glb
Binary file not shown.
Binary file removed gui/assets/thystame.glb
Binary file not shown.
Binary file removed gui/assets/tile.glb
Binary file not shown.
Binary file added gui/assets/tile/tile.glb
Binary file not shown.
83 changes: 50 additions & 33 deletions gui/include/Assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,72 @@

#define PATH_ASSETS "gui/assets/"

#define MODEL_TILE PATH_ASSETS "tile.glb"
#define MODEL_FOOD PATH_ASSETS "food.glb"
#define MODEL_LINEMATE PATH_ASSETS "linemate.glb"
#define MODEL_MENDIANE PATH_ASSETS "mendiane.glb"
#define MODEL_PHIRAS PATH_ASSETS "phiras.glb"
#define MODEL_SIBUR PATH_ASSETS "sibur.glb"
#define MODEL_THYSTAME PATH_ASSETS "thystame.glb"
#define MODEL_DERAUMERE PATH_ASSETS "deraumere.glb"
#define MODEL_PLAYER PATH_ASSETS "player.glb"
#define MODEL_EGG PATH_ASSETS "egg.glb"

#define SIZE_TILE 6

#define SCALE_FOOD (Vector3){2, 2, 2}
#define SCALE_LINEMATE (Vector3){0.05, 0.05, 0.05}
#define PATH_RESOURCES "resources/"
#define PATH_PLAYER "player/"
#define PATH_TILE "tile/"
#define PATH_DECORATION "decoration/"

#define MODEL_TILE PATH_ASSETS PATH_TILE "tile.glb"
#define MODEL_FOOD PATH_ASSETS PATH_RESOURCES "food.glb"
#define MODEL_LINEMATE PATH_ASSETS PATH_RESOURCES "linemate.glb"
#define MODEL_MENDIANE PATH_ASSETS PATH_RESOURCES "mendiane.glb"
#define MODEL_PHIRAS PATH_ASSETS PATH_RESOURCES "phiras.glb"
#define MODEL_SIBUR PATH_ASSETS PATH_RESOURCES "sibur.glb"
#define MODEL_THYSTAME PATH_ASSETS PATH_RESOURCES "thystame.glb"
#define MODEL_DERAUMERE PATH_ASSETS PATH_RESOURCES "deraumere.glb"
#define MODEL_PLAYER PATH_ASSETS PATH_PLAYER "player.glb"
#define MODEL_EGG PATH_ASSETS PATH_PLAYER "egg.glb"
#define MODEL_TREE PATH_ASSETS PATH_DECORATION "tree.glb"
#define MODEL_LANTERN PATH_ASSETS PATH_DECORATION "lantern.glb"

#define SIZE_TILE 4.7

#define PLAYER_HEIGHT 2

#define SCALE_FOOD (Vector3){1, 0.5, 1}
#define SCALE_LINEMATE (Vector3){0.1, 0.1, 0.1}
#define SCALE_MENDIANE (Vector3){0.1, 0.1, 0.1}
#define SCALE_PHIRAS (Vector3){0.2, 0.2, 0.2}
#define SCALE_SIBUR (Vector3){0.2, 0.2, 0.2}
#define SCALE_THYSTAME (Vector3){0.2, 0.2, 0.2}
#define SCALE_PHIRAS (Vector3){0.001, 0.001, 0.005}
#define SCALE_SIBUR (Vector3){0.01, 0.01, 0.01}
#define SCALE_THYSTAME (Vector3){2, 2, 2}
#define SCALE_DERAUMERE (Vector3){0.5, 0.5, 0.5}
#define SCALE_PLAYER (Vector3){0.5, 0.5, 0.5}
#define SCALE_EGG (Vector3){0.75, 0.75, 0.75}
#define SCALE_EGG (Vector3){0.5, 0.5, 0.5}
#define SCALE_TREE (Vector3){1, 1, 1}
#define SCALE_LANTERN (Vector3){1, 1, 1}

#define ROTATION_ANGLE_FOOD 270
#define ROTATION_ANGLE_FOOD 45
#define ROTATION_ANGLE_LINEMATE 270
#define ROTATION_ANGLE_MENDIANE 270
#define ROTATION_ANGLE_PHIRAS 180
#define ROTATION_ANGLE_MENDIANE 0
#define ROTATION_ANGLE_PHIRAS 270
#define ROTATION_ANGLE_SIBUR 270
#define ROTATION_ANGLE_THYSTAME 0
#define ROTATION_ANGLE_DERAUMERE 0
#define ROTATION_ANGLE_PLAYER 0
#define ROTATION_ANGLE_EGG 270
#define ROTATION_ANGLE_TREE 0
#define ROTATION_ANGLE_LANTERN 0

#define ROTATION_AXIS_FOOD (Vector3){1, 0, 0}
#define ROTATION_AXIS_FOOD (Vector3){0, 1, 0}
#define ROTATION_AXIS_LINEMATE (Vector3){1, 0, 0}
#define ROTATION_AXIS_MENDIANE (Vector3){1, 0, 0}
#define ROTATION_AXIS_PHIRAS (Vector3){1, 0, 0}
#define ROTATION_AXIS_SIBUR (Vector3){1, 0, 0}
#define ROTATION_AXIS_THYSTAME (Vector3){0, 0, 0}
#define ROTATION_AXIS_DERAUMERE (Vector3){0, 0, 0}
#define ROTATION_AXIS_PLAYER (Vector3){0, 0, 0}
#define ROTATION_AXIS_PLAYER (Vector3){0, 1, 0}
#define ROTATION_AXIS_EGG (Vector3){1, 0, 0}
#define ROTATION_AXIS_TREE (Vector3){1, 0, 0}
#define ROTATION_AXIS_LANTERN (Vector3){1, 0, 0}

#define POS_FOOD (Vector3){0.5, 0.1, 1.5}
#define POS_LINEMATE (Vector3){1, 0.1, -0.5}
#define POS_MENDIANE (Vector3){2, 0.25, -0.5}
#define POS_PHIRAS (Vector3){0.5, 0.5, -1.5}
#define POS_SIBUR (Vector3){1.5, 0.1, -1.5}
#define POS_THYSTAME (Vector3){1, 0.2, -2}
#define POS_DERAUMERE (Vector3){2, 0.1, -2}
#define POS_PLAYER (Vector3){0, 0.1, 0}
#define POS_EGG (Vector3){0.5, 0.5, 0.5}
#define POS_FOOD (Vector3){0.5, -0.1, 1.5}
#define POS_LINEMATE (Vector3){1, -0.3, -0.5}
#define POS_MENDIANE (Vector3){2, -0.25, -0.5}
#define POS_PHIRAS (Vector3){0.5, -0.3, -1.5}
#define POS_SIBUR (Vector3){1.5, -0.3, -1.5}
#define POS_THYSTAME (Vector3){1, -0.2, -2}
#define POS_DERAUMERE (Vector3){2, -0.3, -2}
#define POS_PLAYER (Vector3){0, -0.25, 0}
#define POS_EGG (Vector3){0.5, 0, 0.5}
#define POS_TREE (Vector3){2, -0.3, 2}
#define POS_LANTERN (Vector3){1, -0.3, 2}
59 changes: 57 additions & 2 deletions gui/include/Event/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ class Gui::Event {
*/
void setRender(std::shared_ptr<Render> render);

/**
* @brief Set the GameData object.
*
* @param gameData GameData class.
*/
void setGameData(std::shared_ptr<GameData> gameData);

private:

std::shared_ptr<Render> _render; // Render class to draw scene.
std::shared_ptr<Render> _render; // Render class to draw scene.
std::shared_ptr<GameData> _gameData; // GameData class to contain scene.

/**
* @brief Map for events by down key.
Expand All @@ -74,7 +82,18 @@ class Gui::Event {
std::unordered_map<KeyboardKey, std::function<void()>> _eventsKeyPressed =
{
{KEY_THREE, [this](){switchDisplayDebug();}},
{KEY_F3, [this](){switchDisplayDebug();}}
{KEY_F3, [this](){switchDisplayDebug();}},
{KEY_SPACE, [this](){setFreeCam();}},
};

/**
* @brief Map for events by pressing mouse.
*
*/
std::unordered_map<MouseButton, std::function<void()>> _eventsMousePressed =
{
{MOUSE_BUTTON_LEFT, [this](){handleLeftClick();}},
{MOUSE_BUTTON_RIGHT, [this](){handleRightClick();}}
};

/**
Expand All @@ -94,4 +113,40 @@ class Gui::Event {
*
*/
void switchDisplayDebug();

/**
* @brief Set the free camera.
*/
void setFreeCam();

/**
* @brief Handle the left click.
*
*/
void handleLeftClick();

/**
* @brief Handle the right click.
*/
void handleRightClick();

/**
* @brief Select the player pov.
*
*/
void selectPlayer();

/**
* @brief Change the player.
*
* @param turn Turn to select the player.
*/
void changePlayer(bool turn);

/**
* @brief Change the camera to the player.
*
* @param player Player to select.
*/
void changeCameraToPlayer(size_t id);
};
24 changes: 16 additions & 8 deletions gui/include/GameDatas/GameData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@

#pragma once

#include "Types.hpp"
#include "Error/Error.hpp"
#include "GameDatas/Team.hpp"
#include "GameDatas/Tile.hpp"

#define NO_TICK int(-1)

/**
* @brief Map type.
*
* @tparam T Type of the map.
*/
template<typename T>
using Map = std::vector<std::vector<T>>;

namespace Gui {

/**
Expand Down Expand Up @@ -85,6 +78,13 @@ class Gui::GameData {
*/
void addPlayerToTeam(const std::string &teamName, const Gui::Player &player);

/**
* @brief Get a player object.
*
* @param id Id of the player.
*/
Gui::Player &getPlayer(size_t id);

/**
* @brief Get the Map object.
*
Expand Down Expand Up @@ -189,6 +189,14 @@ class Gui::GameData {
*/
std::string getLastError() const;

/**
* @brief Get the Team From Player object.
*
* @param id Id of the player.
* @return Gui::Team& Team of the player.
*/
Team &getTeamById(std::size_t id);

private:

std::vector<Gui::Team> _teams; // Teams of the game.
Expand Down
17 changes: 16 additions & 1 deletion gui/include/GameDatas/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include "raylib.h"
#include "GameDatas/Inventory.hpp"

namespace Gui {
Expand Down Expand Up @@ -148,7 +149,21 @@ class Gui::Player {
*
* @return std::string - Broadcast message.
*/
std::string getBroadcast(void) const;
std::string getBroadcast() const;

/**
* @brief Get the Vector From Orientation object.
*
* @return Vector3 - Vector3 from orientation.
*/
float getRotationFromOrientation() const;

/**
* @brief Get the Center Position object.
*
* @return Vector3 - Center position.
*/
Vector3 getCenterPosition();

/**
* @brief Inventory of the player.
Expand Down
48 changes: 48 additions & 0 deletions gui/include/GameDatas/Team.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#pragma once

#include "raylib.h"
#include "Types.hpp"
#include "GameDatas/Egg.hpp"
#include "GameDatas/Tile.hpp"
#include "GameDatas/Player.hpp"

#include <vector>
Expand Down Expand Up @@ -146,11 +148,57 @@ class Gui::Team {
*/
void setEggModelPath(const std::string &eggModelPath);

/**
* @brief Get the Player Boundig Boxes object.
*
* @param pos Position of the player.
* @param orientation Orientation of the player.
* @return std::vector<BoundingBox> Bounding boxes of the player.
*/
std::vector<BoundingBox> getPlayerBoundingBoxes(std::pair<size_t, size_t> pos, size_t orientation, Vector3 center);

/**
* @brief Get the Player position in 3D space.
*
* @param id Id of the player.
* @param map Map of the game.
*/
Vector3 getPlayerPositionIn3DSpace(size_t id, Map<Tile> map);

/**
* @brief Get the Player Model hitbox.
*
* @param id Id of the player.
* @param camera Camera of the game.
* @return std::vector<RayCollision> Hitbox of the player.
*/
std::vector<RayCollision> getPlayerModelHitbox(size_t id, Camera camera);

/**
* @brief Check if the player is hit.
*
* @param id Id of the player.
* @param camera Camera of the game.
* @return true If the player is hit.
*/
bool isPlayerHit(size_t id, Camera camera);

private:

std::string _name; // Name of the team.
std::vector<Gui::Player> _players; // Players of the team.
Model _playerModel; // Model player asset of the team.
std::vector<Gui::Egg> _eggs; // Eggs of the team.
Model _eggModel; // Eggs Model of the team.

/**
* @brief Rotate a bounding box by orientation.
*
* @param bbox Bounding box to rotate.
* @param orientation Orientation of the player.
* @param pos Position of the player.
* @param center Center of the player.
* @return BoundingBox Rotated bounding box.
*/
BoundingBox rotateBoundingBoxByOrientation(BoundingBox bbox, size_t orientation, std::pair<size_t, size_t> pos, Vector3 center);
};
Loading

0 comments on commit a4ada7c

Please sign in to comment.