Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

project(anal
VERSION 1.1.0
VERSION 1.2.0
DESCRIPTION "Arcade Native Agnostic Layer"
LANGUAGES CXX
)
Expand Down
27 changes: 27 additions & 0 deletions include/ANAL/IArcade.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
** EPITECH PROJECT, 2025
** anal
** File description:
** IArcade.hpp
*/

#ifndef IARCADE_HPP
#define IARCADE_HPP
#include <memory>

#include "IAsset.hpp"
#include "IEntity.hpp"

namespace ANAL
{
class IArcade
{
public:
IArcade() = default;
virtual ~IArcade() = default;

[[nodiscard]] virtual std::unique_ptr<IAsset> newAsset() const = 0;
[[nodiscard]] virtual std::unique_ptr<IEntity> newEntity() const = 0;
Comment thread
Dawoox marked this conversation as resolved.
};
}
#endif //IARCADE_HPP
27 changes: 13 additions & 14 deletions include/ANAL/IAsset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,37 @@
namespace ANAL
{
/**
* @interface IAsset
* @brief Interface to describe an asset
* @details Details about an asset, meaning it's texture and alternative render modes
*/
* @interface IAsset
* @brief Interface for assets
*/
class IAsset
{
public:
IAsset() = default;
virtual ~IAsset() = default;

/**
* @brief set the path to the asset texture
* @brief Set the path to the asset texture resource file
*/
virtual void setTexturePath(const std::string&) = 0;

/**
* @brief set the alternate render of the asset
* @param alternateRender the character rendered in place of the texture
* @brief Get the path to the asset texture resource file
* @return Path to the resource file, can be absolute or relative
*/
virtual void setAlternativeRender(char alternateRender) = 0;
[[nodiscard]] virtual const std::string& getTexturePath() const = 0;

/**
* @brief get the path to the asset texture
* @return the path to the asset texture
* @brief Set the alternate render display of the asset
* @details This character represent what will be shown if the renderer doesn't support graphical mode
*/
virtual const std::string& getTexturePath() const = 0;
virtual void setAlternateRender(char) = 0;

/**
* @brief get the alternate render of the asset
* @return the alternate render
* @brief Get the alternate render display of the asset
* @return The alternate render character
*/
virtual char getAlternativeRender() const = 0;
[[nodiscard]] virtual char getAlternateRender() const = 0;
};
}
#endif //IASSET_HPP
55 changes: 55 additions & 0 deletions include/ANAL/IEntity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
** EPITECH PROJECT, 2025
** anal
** File description:
** IEntity.hpp
*/

// ReSharper disable CppClassCanBeFinal
#ifndef IENTITY_HPP
#define IENTITY_HPP

#include "IAsset.hpp"
#include "Vector2.hpp"

/**
* @brief Arcade Native Agnostic Layer
* @details Namespace containing all the standardized interfaces for the Arcade project
*/
namespace ANAL
{
/**
* @interface IEntity
* @brief Interface for entities
*/
class IEntity
{
public:
IEntity() = default;
virtual ~IEntity() = default;

/**
* @brief Set the entity position
* @note The rendering is a grid of 10x10, thus the value of any position shouldn't exceed 9 or the entity would be rendered offscreen!
*/
virtual void setPos(Vector2<int>) = 0;

/**
* @brief Get the current entity position
* @return The position vector
*/
[[nodiscard]] virtual Vector2<int>& getPos() const = 0;

/**
* @brief Set the entity asset used when rendering
*/
virtual void setAsset() = 0;

/**
* @brief Get the current entity asset
* @return The entity asset
*/
[[nodiscard]] virtual const IAsset& getAsset() const = 0;
};
}
#endif //IENTITY_HPP
9 changes: 7 additions & 2 deletions include/ANAL/IGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <vector>

#include "Events.hpp"
#include "IModule.hpp"
#include "IArcade.hpp"
#include "IRenderer.hpp"

/**
Expand Down Expand Up @@ -52,10 +52,15 @@ namespace ANAL
/**
* @brief Render the game to the renderer sprite/text queue
* @param renderer Current Renderer that should be used
* @param arcade Arcade core, used to create new Asset or Entity
*/
virtual void render(IRenderer& renderer) = 0;
virtual void render(IRenderer& renderer, IArcade& arcade) = 0;
};
}

/**
* @brief Game module entrypoint
* @return Unique ptr on a new IGame instance
*/
extern "C" std::unique_ptr<ANAL::IGame> uwu_entrypoint_game(void);
#endif //IGAME_HPP
1 change: 1 addition & 0 deletions include/ANAL/IModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace ANAL
UNKNOWN,
V1_0_0,
V1_1_0,
V1_2_0,
NOT_SUPPORTED,
};
}
Expand Down
32 changes: 15 additions & 17 deletions include/ANAL/IRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#include <vector>

#include "Events.hpp"
#include "IModule.hpp"
#include "ISprite.hpp"
#include "IEntity.hpp"
#include "Vector2.hpp"

/**
Expand All @@ -42,22 +41,17 @@ namespace ANAL
class Exception : public std::exception {};

/**
* @brief Sprite factory
* @return an allocated new sprite
* @brief Draw an entity
* @details Draw the entity at its current position on the window buffer
* @param entity Entity to be rendered; is immutable.
* @throw IRenderer::Exception Throw when cannot draw the entity
*/
virtual std::unique_ptr<ISprite> newSprite() const = 0;
virtual void drawEntity(const IEntity& entity) = 0;

/**
* @brief Draw a sprite in the frame buffer
* @details Add a sprite to the sprite queue that will be rendered to the window buffer on the next render call
* @param sprite sprite to be rendered; is immutable.
*/
virtual void drawSprite(const ISprite& sprite) = 0;

/**
* @brief Draw a text in the frame buffer
* @details Add a text to the text queue that will be rendered to the window buffer on the next render call
* @note The text render buffer will always be on top of the sprite buffer
* @brief Draw a text
* @details Draw the text at its current position on the window buffer
* @throw IRenderer::Exception Throw when cannot draw the text
*/
virtual void drawText(const std::string&, Vector2<int>) = 0;

Expand All @@ -69,19 +63,23 @@ namespace ANAL
/**
* @brief Render the render queues on the window buffer
* @details Render first the sprite queue, then the text queue
* @throw IRenderer::exception If couldn't render
* @throw IRenderer::Exception If couldn't render
*/
virtual void render() = 0;

virtual std::vector<Event>& getEvents() = 0;

/**
* @brief Clear the entire window in black
* @note Act directly on the window buffer, not the sprite/text queue, will not wait for the next render
* @note Act directly on the window buffer, will not wait for the next render
*/
virtual void clear() = 0;
};
}

/**
* @brief Renderer module entrypoint
* @return Unique ptr on a new IRenderer instance
*/
extern "C" std::unique_ptr<ANAL::IRenderer> uwu_entrypoint_renderer(void);
#endif //IRENDERER_HPP
65 changes: 0 additions & 65 deletions include/ANAL/ISprite.hpp
Original file line number Diff line number Diff line change
@@ -1,65 +0,0 @@
/*
** EPITECH PROJECT, 2025
** anal
** File description:
** ISprite.hpp
*/

// ReSharper disable CppClassCanBeFinal
#ifndef ISPRITE_HPP
#define ISPRITE_HPP

#include <utility>

#include "IAsset.hpp"
#include "Vector2.hpp"

/**
* @brief Arcade Native Agnostic Layer
* @details Namespace containing all the standardized interfaces for the Arcade project
*/
namespace ANAL
{
/**
* @interface ISprite
* @brief Interface for all game sprites, meaning a current objet with a texture and a position
* @exception ISprite::Exception
*/
class ISprite
{
public:
ISprite() = default;
virtual ~ISprite() = default;

/**
* @exception Exception
* @brief Sprite exception
*/
class Exception : public std::exception {};

/**
* @brief Sprite position getter
* @return the current sprite position
*/
virtual const Vector2<int>& getPos() const = 0;

/**
* @brief Sprite position setter
* @param vecPos the new sprite position
*/
virtual void setPos(Vector2<int> vecPos) = 0;

/**
* @brief Sprite asset getter
* @return the current sprite asset
*/
virtual const IAsset& getAsset() const = 0;

/**
* @brief Sprite asset setter
* @param asset the new sprite asset
*/
virtual void setAsset(IAsset& asset) = 0;
};
}
#endif //ISPRITE_HPP