Skip to content

Commit

Permalink
merge: merge new shared version
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann-Masson committed Apr 6, 2024
1 parent 383fe98 commit 12a11a8
Show file tree
Hide file tree
Showing 33 changed files with 625 additions and 308 deletions.
5 changes: 5 additions & 0 deletions shared/Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INPUT = .
RECURSIVE = YES
GENERATE_LATEX = NO
PROJECT_NAME = "Arcade Shared"
USE_MDFILE_AS_MAINPAGE = "README.md"
27 changes: 27 additions & 0 deletions shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,30 @@ This library contains shared code for the Arcade project in order to unify inter

- **[Carapace Retro](https://github.com/G-Epitech)** : [Baptiste Moreau](https://github.com/BxptisteM), [Axel Fradet](https://github.com/AxelF44) & [Suceveanu Dragos](https://github.com/sdragos1)

## How ?

Our arcade simulator relies on a modular development model, utilizing dynamic libraries to separate game logic from graphical display. This system revolves around two types of libraries: game libraries and graphical libraries. These two libraries operate entirely independently, focusing solely on the principle of getters and setters for data manipulation.

1. Game Libraries:

Game libraries are responsible for managing the internal game logic, including gameplay mechanics, collisions, levels, and more. They provide functionalities through getter and setter methods, allowing developers to access and modify game data as needed.

2. Graphical Libraries:

On the other hand, graphical libraries handle the visual display of the game. They include features such as sprite rendering, animation management, and special effects. These libraries also interact with the simulator solely through getter and setter methods, enabling the modification of visual properties of game elements.

3. Core:

To ensure consistency and communication between game libraries and graphical libraries, a "core" is necessary. This core acts as a central liaison, coordinating game data with graphical display. It retrieves information about the game state from game libraries and passes it to graphical libraries for display. Similarly, it monitors user interactions and updates game data accordingly, ensuring a smooth gaming experience.

In summary, our arcade simulator relies on a modular development model where game libraries, graphical libraries, and the core interact independently, providing maximum flexibility and enabling developers to create unique and dynamic gaming experiences.

## Documentation

If you want the code documentation you can run this command :

```bash
doxygen Doxyfile
```

This command allow you to generate Doxygen documentation.
51 changes: 27 additions & 24 deletions shared/games/IEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,38 @@
#include <vector>
#include <memory>

namespace shared::games
{
class IGame;
namespace shared::games {
class IGame;

namespace entity
{
class IEntity;
namespace entity {
class IEntity;

typedef std::shared_ptr<IEntity> EntityPtr;
typedef std::vector<EntityPtr> EntitiesMap;
}
/// @brief Entity pointer
typedef std::shared_ptr<IEntity> EntityPtr;
/// @brief Entities map pointers
typedef std::vector<EntityPtr> EntitiesMap;
}

namespace components
{
class IComponent;
namespace components {
class IComponent;

typedef std::vector<std::shared_ptr<IComponent>> ComponentsMap;
}
/// @brief Components map pointers
typedef std::vector<std::shared_ptr<IComponent>> ComponentsMap;
}
}

class shared::games::entity::IEntity
{
/**
* @brief Interface of an entity
*
*/
class shared::games::entity::IEntity {
public:
virtual ~IEntity() = default;

/**
* @brief Get the components of the entity
*
* @return Components of the entity
*/
virtual const components::ComponentsMap &getComponents(void) const noexcept = 0;
virtual ~IEntity() = default;

/**
* @brief Get the components of the entity
*
* @return Components of the entity
*/
virtual const components::ComponentsMap &getComponents(void) const noexcept = 0;
};
91 changes: 47 additions & 44 deletions shared/games/IGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,61 @@

using namespace shared::types;

namespace shared::games
{
class IGame;
namespace shared::games {
class IGame;

typedef std::chrono::duration<double, std::milli> DeltaTime;
/// @brief Delta time in milliseconds
typedef std::chrono::duration<double, std::milli> DeltaTime;
}

class shared::games::IGame
{
/**
* @brief Interface of a game
*
*/
class shared::games::IGame {
public:
virtual ~IGame() = default;
virtual ~IGame() = default;

/**
* @brief Compute the game each tick of the program
*
* @param dt Time since last tick (Time in `milliseconds`)
*/
virtual void compute(DeltaTime dt) = 0;
/**
* @brief Compute the game each tick of the program
*
* @param dt Time since last tick (Time in `milliseconds`)
*/
virtual void compute(DeltaTime dt) = 0;

/**
* @brief Manifest with informations of the game
*
* @return Manifest of the game
*/
virtual const GameManifest &getManifest() const noexcept = 0;
/**
* @brief Manifest with informations of the game
*
* @return Manifest of the game
*/
virtual const GameManifest &getManifest() const noexcept = 0;

/**
* @brief Number of tiles that represent the game
* Tile size is managed by the renderer
*
* @return The number of tiles of the game
*/
virtual const Vector2u getSize() const noexcept = 0;
/**
* @brief Number of tiles that represent the game
* Tile size is managed by the renderer
*
* @return The number of tiles of the game
*/
virtual const Vector2u getSize() const noexcept = 0;

/**
* @brief Get fps of the game
*
* @return The number of frame per seconds of the game
*/
virtual const unsigned int getFps() const noexcept = 0;
/**
* @brief Get fps of the game
*
* @return The number of frame per seconds of the game
*/
virtual const unsigned int getFps() const noexcept = 0;

/**
* @brief Get map of entities
*
* @return Entities map of the game
*/
virtual const entity::EntitiesMap &getEntities(void) const = 0;
/**
* @brief Get map of entities
*
* @return Entities map of the game
*/
virtual const entity::EntitiesMap &getEntities(void) const = 0;

/**
* @brief Get the score of the game
*
* @return The score of the game
*/
virtual const int getScore() const noexcept = 0;
/**
* @brief Get the score of the game
*
* @return The score of the game
*/
virtual const int getScore() const noexcept = 0;
};
33 changes: 18 additions & 15 deletions shared/games/IGameProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@ namespace shared::games {
class IGameProvider;
}

class shared::games::IGameProvider
{
/**
* @brief Interface of a game provider
*
*/
class shared::games::IGameProvider {
public:
virtual ~IGameProvider() = default;
virtual ~IGameProvider() = default;

/**
* @brief Provides the game manifest
*
* @return Manifest of current game
*/
virtual const GameManifest &getManifest() const noexcept = 0;
/**
* @brief Provides the game manifest
*
* @return Manifest of current game
*/
virtual const GameManifest &getManifest() const noexcept = 0;

/**
* @brief Provides a new instance of the game
*
* @return Created game instance
*/
virtual std::shared_ptr<shared::games::IGame> createInstance(void) = 0;
/**
* @brief Provides a new instance of the game
*
* @return Created game instance
*/
virtual std::shared_ptr<shared::games::IGame> createInstance(void) = 0;
};
23 changes: 13 additions & 10 deletions shared/games/components/ICollidableComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@
#include "../../types/Vector.hpp"

namespace shared::games::components {
class ICollidableComponent;
class ICollidableComponent;
}

class shared::games::components::ICollidableComponent: public virtual IPositionableComponent
{
/**
* @brief Interface of a collidable component
*
*/
class shared::games::components::ICollidableComponent: public virtual IPositionableComponent {
public:
virtual ~ICollidableComponent() = default;
virtual ~ICollidableComponent() = default;

/**
* @brief On collide event handler for the component
* @param ctx Context of the game
* @param target Target entity
*/
virtual void onCollide(std::shared_ptr<IGame> ctx, std::shared_ptr<ICollidableComponent> target) = 0;
/**
* @brief On collide event handler for the component
* @param ctx Context of the game
* @param target Target entity
*/
virtual void onCollide(std::shared_ptr<IGame> ctx, std::shared_ptr<ICollidableComponent> target) = 0;
};
27 changes: 20 additions & 7 deletions shared/games/components/IComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,32 @@
#include "../IEntity.hpp"

namespace shared::games::components {

/// @brief Enum of component types
typedef enum {
TEXTURE,
TEXT,
DISPLAYABLE,
SOUND,
COLLIDABLE,
POSITIONABLE,
KEYBOARD
/// @brief Component type for a texture
TEXTURE,
/// @brief Component type for a text
TEXT,
/// @brief Component type for a displayable
DISPLAYABLE,
/// @brief Component type for a sound
SOUND,
/// @brief Component type for a collidable
COLLIDABLE,
/// @brief Component type for a positionable
POSITIONABLE,
/// @brief Component type for a keyboard
KEYBOARD
} ComponentType;

class IComponent;
}

/**
* @brief Interface of a component
*
*/
class shared::games::components::IComponent {
public:
virtual ~IComponent() = default;
Expand Down
5 changes: 5 additions & 0 deletions shared/games/components/IDisplayableComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ namespace shared::games::components {
class IDisplayableComponent;
}

/**
* @brief Interface of a displayable component
*
*/
class shared::games::components::IDisplayableComponent : public virtual IPositionableComponent {
public:
virtual ~IDisplayableComponent() = default;

/**
* @brief Get Z index that is usefull for display prioroty
*
* @return Z index of the entity
*/
virtual unsigned int &getZIndex() noexcept = 0;

Expand Down
Loading

0 comments on commit 12a11a8

Please sign in to comment.