Skip to content

Commit

Permalink
merge: Merge pull request #9 from G-Epitech/7-project-folder-architec…
Browse files Browse the repository at this point in the history
…ture

Project folder architecture
  • Loading branch information
Yann-Masson authored Mar 22, 2024
2 parents b3cb046 + a6ceab2 commit c7f6dd3
Show file tree
Hide file tree
Showing 52 changed files with 1,651 additions and 37 deletions.
13 changes: 0 additions & 13 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
## Related Tickets & Documents

- Related Issue #
- Closes (optional) #

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [ ] Optimization
- [ ] Documentation Update

## Changes made

_Please replace this line with a description of the changes in this PR. Include
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## CMake
build
cmake-build-debug

## MacOS
.DS_Store
Expand All @@ -8,8 +9,13 @@ build
.vscode
.idea

## Github
common/.github
common/.gitignore

## Binary
arcade
lib
*.gcno
*.gcda
*.o
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
cmake_minimum_required(VERSION 3.27)
project(arcade)

set(ARCADE_BIN_DIR ${CMAKE_CURRENT_LIST_DIR})
set(ARCADE_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/lib)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")

add_subdirectory(src)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ARCADE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ARCADE_LIB_DIR})
set(CMAKE_SHARED_LIBRARY_PREFIX "arcade_")

add_subdirectory(core)
add_subdirectory(games)
add_subdirectory(graphics)

target_include_directories (arcade PUBLIC ${CMAKE_CURRENT_LIST_DIR}/common/)
7 changes: 0 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ pipeline {
agent any

stages {
stage('Project setup') {
steps {
sh 'git rm --cached common'
sh 'make update'
}
}

stage('Project compilation') {
agent {
docker {
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
## Makefile
##

NAME = arcade
BUILD_PATH = build
NAME = arcade
BUILD_PATH = build
LIB_PATH = lib

all: update
@cmake -S . -B build
cmake --build $(BUILD_PATH)
@cp $(BUILD_PATH)/src/$(NAME) .
all:
@cmake -S . -B build
cmake --build $(BUILD_PATH)

clean:
@rm -rf $(BUILD_PATH)
@rm -rf $(BUILD_PATH)

fclean: clean
@rm -f $(NAME)
@rm -f $(NAME)
@rm -rf $(LIB_PATH)

re: fclean all
re: fclean all

tests_run:
echo "pass"
echo "pass"

update:
@git submodule init
@git submodule update
@cd common && ./pull.sh .

.PHONY: all clean fclean re tests_run update
DEFAULT_GOAL := all
1 change: 0 additions & 1 deletion common
Submodule common deleted from 740723
11 changes: 11 additions & 0 deletions common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 📦 Arcade Shared Library
Shared library for Arcade project

## Description
This library contains shared code for the Arcade project in order to unify interfaces between collaborative groups.

## Groups
- **[G-Epitech](https://github.com/G-Epitech/FMY-Arcade)** : [Flavien Chenu](https://github.com/flavien-chenu), [Math](https://github.com/tekmath) & [Yann Masson](https://github.com/Yann-Masson)

- **[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)

52 changes: 52 additions & 0 deletions common/games/IEntity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
** EPITECH PROJECT, 2024
** arcade-shared
** File description:
** IEntity
*/

#pragma once

#include <map>
#include <memory>

#include "../types/UUId.hpp"

namespace shared::games
{
class IGame;

namespace entity
{
class IEntity;

typedef std::map<types::UUId, std::shared_ptr<IEntity>> EntitiesMap;
}

namespace components
{
class IComponent;

typedef std::map<types::UUId, std::shared_ptr<IComponent>> ComponentsMap;
}
}

class shared::games::entity::IEntity
{
public:
virtual ~IEntity() = default;

/**
* @brief Get the id of the entity
*
* @return Entity unique id
*/
virtual const types::UUId &getId(void) const noexcept = 0;

/**
* @brief Get the components of the entity
*
* @return Components of the entity
*/
virtual const components::ComponentsMap &getComponents(void) const noexcept = 0;
};
68 changes: 68 additions & 0 deletions common/games/IGame.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
** EPITECH PROJECT, 2024
** shared-arcade
** File description:
** IGame
*/

#pragma once

#include <memory>
#include "IEntity.hpp"
#include "../types/types.hpp"
#include "types/GameManifest.hpp"

using namespace shared::types;

namespace shared::games
{
class IGame;

typedef unsigned long DeltaTime;
}

class shared::games::IGame
{
public:
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 Manifest with informations of the game
*
*/
virtual const GameManifest &getManifest(void) const noexcept = 0;

/**
* @brief The minimum window size required for the game (pixels)
*
*/
virtual const Vector2u getWindowMinSize(void) const noexcept = 0;

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

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

/**
* @brief Get entity by id
*
* @param id Id of the entity
* @return The specific entity
*/
virtual std::shared_ptr<entity::IEntity> getEntityById(const UUId &id) const = 0;
};
36 changes: 36 additions & 0 deletions common/games/IGameProvider.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
** EPITECH PROJECT, 2024
** arcade-shared
** File description:
** IGameProvider
*/

#pragma once

#include <memory>
#include "IGame.hpp"
#include "types/GameManifest.hpp"

namespace shared::games {
class IGameProvider;
}

class shared::games::IGameProvider
{
public:
virtual ~IGameProvider() = default;

/**
* @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<game::IGame> createInstance(void) = 0;
};
29 changes: 29 additions & 0 deletions common/games/components/ICollidableComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
** EPITECH PROJECT, 2024
** arcade-shared
** File description:
** ICollidableComponent
*/

#pragma once

#include "../IGame.hpp"
#include "IPositionComponent.hpp"
#include "../../types/Vector.hpp"

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

class shared::games::components::ICollidableComponent: public virtual IPositionComponent
{
public:
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;
};
49 changes: 49 additions & 0 deletions common/games/components/IComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
** EPITECH PROJECT, 2024
** arcade-shared
** File description:
** IComponent
*/

#pragma once

#include "../IEntity.hpp"
#include "../../types/UUId.hpp"

namespace shared::games::components {
typedef enum {
DISPLAYABLE,
SOUND,
COLLIDABLE,
POSITION,
KEYBOARD
} ComponentType;

class IComponent;
}

class shared::games::components::IComponent {
public:
virtual ~IComponent() = default;

/**
* @brief Get the type of the component
*
* @return Type of the component
*/
virtual const ComponentType getType() const noexcept = 0;

/**
* @brief Get the uuid of component
*
* @return Component id
*/
virtual const types::UUId &getId() const noexcept = 0;

/**
* @brief Get the parent entity of the component
*
* @return Entity of the component
*/
virtual std::shared_ptr<entity::IEntity> getEntity() noexcept = 0;
};
Loading

0 comments on commit c7f6dd3

Please sign in to comment.