From 98e11b10fded9dac157da565a736d9cd8bcb9c4e Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Wed, 19 May 2021 10:08:54 +0200 Subject: [PATCH] compile lib --- lib/Ray/CMakeLists.txt | 112 +++++++++++----------- lib/Ray/include/Camera/Camera2D.hpp | 2 +- lib/Ray/include/Camera/Camera3D.hpp | 2 +- lib/Ray/include/Controllers/Gamepad.hpp | 2 +- lib/Ray/include/Drawables/ADrawable2D.hpp | 4 +- lib/Ray/include/Drawables/IDrawable.hpp | 21 ++-- lib/Ray/src/Audio/Music.cpp | 1 + lib/Ray/src/Audio/Sound.cpp | 1 + lib/Ray/src/Camera/Camera2D.cpp | 2 +- lib/Ray/src/Camera/Camera3D.cpp | 4 +- lib/Ray/src/Controllers/Gamepad.cpp | 2 +- lib/Ray/src/Drawables/ADrawable2D.cpp | 45 +++++++++ lib/Ray/src/Font.cpp | 1 + lib/Ray/src/Model.cpp | 2 + lib/Ray/src/Window.cpp | 10 +- 15 files changed, 131 insertions(+), 80 deletions(-) create mode 100644 lib/Ray/src/Drawables/ADrawable2D.cpp diff --git a/lib/Ray/CMakeLists.txt b/lib/Ray/CMakeLists.txt index c4fdbe00..97c193e3 100644 --- a/lib/Ray/CMakeLists.txt +++ b/lib/Ray/CMakeLists.txt @@ -5,68 +5,68 @@ set(LIB_NAME "ray") project("${LIB_NAME}") include_directories("./include") -target_link_libraries(${LIB_NAME} raylib) if (CMAKE_COMPILER_IS_GNUCXX) - set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -Werror -Wshadow") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") +set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -Werror -Wshadow") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") endif () set(HEADERS - include/Canvas.hpp - include/Color.hpp - include/Font.hpp - include/IRessource.hpp - include/Matrix.hpp - include/Mesh.hpp - include/Model.hpp - include/Vector.hpp - include/Window.hpp - include/Audio/IAudio.hpp - include/Audio/Music.hpp - include/Audio/Sound.hpp - include/Camera/Camera2D.hpp - include/Camera/Camera3D.hpp - include/Camera/CameraMode.hpp - include/Camera/CameraProjection.hpp - include/Camera/ICamera.hpp - include/Controllers/Gamepad.hpp - include/Controllers/Keyboard.hpp - include/Controllers/Mouse.hpp - include/Drawables/ADrawable2D.hpp - include/Drawables/ADrawable3D.hpp - include/Drawables/IDrawable.hpp - include/Drawables/Image.hpp - include/Drawables/Texture.hpp - include/Drawables/2D/Circle.hpp - include/Drawables/2D/Line.hpp - include/Drawables/2D/Point.hpp - include/Drawables/2D/Rectangle.hpp - include/Drawables/2D/Text.hpp - include/Drawables/2D/Triangle.hpp - include/Drawables/3D/Circle.hpp - include/Drawables/3D/Cylinder.hpp - include/Drawables/3D/Grid.hpp - include/Drawables/3D/Line.hpp - include/Drawables/3D/Plane.hpp - include/Drawables/3D/Point.hpp - include/Drawables/3D/Ray.hpp - include/Drawables/3D/Sphere.hpp - include/Drawables/3D/Triangle.hpp - ) +include/Canvas.hpp +include/Color.hpp +include/Font.hpp +include/IRessource.hpp +include/Matrix.hpp +include/Mesh.hpp +include/Model.hpp +include/Vector.hpp +include/Window.hpp +include/Audio/IAudio.hpp +include/Audio/Music.hpp +include/Audio/Sound.hpp +include/Camera/Camera2D.hpp +include/Camera/Camera3D.hpp +include/Camera/CameraMode.hpp +include/Camera/CameraProjection.hpp +include/Camera/ICamera.hpp +include/Controllers/Gamepad.hpp +include/Controllers/Keyboard.hpp +include/Controllers/Mouse.hpp +include/Drawables/ADrawable2D.hpp +include/Drawables/ADrawable3D.hpp +include/Drawables/IDrawable.hpp +include/Drawables/Image.hpp +include/Drawables/Texture.hpp +include/Drawables/2D/Circle.hpp +include/Drawables/2D/Line.hpp +include/Drawables/2D/Point.hpp +include/Drawables/2D/Rectangle.hpp +include/Drawables/2D/Text.hpp +include/Drawables/2D/Triangle.hpp +include/Drawables/3D/Circle.hpp +include/Drawables/3D/Cylinder.hpp +include/Drawables/3D/Grid.hpp +include/Drawables/3D/Line.hpp +include/Drawables/3D/Plane.hpp +include/Drawables/3D/Point.hpp +include/Drawables/3D/Ray.hpp +include/Drawables/3D/Sphere.hpp +include/Drawables/3D/Triangle.hpp +) set(SRC - src/Color.cpp - src/Font.cpp - src/Model.cpp - src/Window.cpp - src/Audio/Music.cpp - src/Audio/Sound.cpp - src/Camera/Camera2D.cpp - src/Camera/Camera3D.cpp - src/Controllers/Gamepad.cpp - src/Controllers/Keyboard.cpp - src/Controllers/Mouse.cpp - ) +src/Color.cpp +src/Font.cpp +src/Model.cpp +src/Window.cpp +src/Audio/Music.cpp +src/Audio/Sound.cpp +src/Camera/Camera2D.cpp +src/Camera/Camera3D.cpp +src/Controllers/Gamepad.cpp +src/Controllers/Keyboard.cpp +src/Controllers/Mouse.cpp +) add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS}) +target_link_libraries(${LIB_NAME} raylib) diff --git a/lib/Ray/include/Camera/Camera2D.hpp b/lib/Ray/include/Camera/Camera2D.hpp index 72249948..54bf8fa3 100644 --- a/lib/Ray/include/Camera/Camera2D.hpp +++ b/lib/Ray/include/Camera/Camera2D.hpp @@ -21,7 +21,7 @@ namespace RAY::Camera { //! @param target Camera target (rotation and zoom origin //! @param rotation Camera rotation in degrees //! @param zoom Camera zoom (scaling), should be 1.0f by default - Camera2D(const Vector2 &offset, Vector2 target, float rotation, float zoom = 1); + Camera2D(const Vector2 &offset, const Vector2 &target, float rotation, float zoom = 1); //! @brief A copy constructor Camera2D(const Camera2D &) = default; diff --git a/lib/Ray/include/Camera/Camera3D.hpp b/lib/Ray/include/Camera/Camera3D.hpp index 6da30d2d..4c3c3f29 100644 --- a/lib/Ray/include/Camera/Camera3D.hpp +++ b/lib/Ray/include/Camera/Camera3D.hpp @@ -24,7 +24,7 @@ namespace RAY::Camera { //! @param up Camera up vector (rotation over its axis) //! @param fovy Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic //! @param projection Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC - Camera3D(const Vector3 &position, Vector3 target, Vector3 up, float fovy, float projection); + Camera3D(const Vector3 &position, const Vector3 &target, const Vector3 &up, float fovy, Projection projection); //! @brief A copy constructor Camera3D(const Camera3D &) = default; diff --git a/lib/Ray/include/Controllers/Gamepad.hpp b/lib/Ray/include/Controllers/Gamepad.hpp index afb5c747..cc82cc18 100644 --- a/lib/Ray/include/Controllers/Gamepad.hpp +++ b/lib/Ray/include/Controllers/Gamepad.hpp @@ -49,7 +49,7 @@ namespace RAY::Controller { bool isUp(Button); //! @brief Returns true if controller is available - bool isAvailable(Button); + bool isAvailable(); //! @brief Sets gamepad's id void setID(int id); diff --git a/lib/Ray/include/Drawables/ADrawable2D.hpp b/lib/Ray/include/Drawables/ADrawable2D.hpp index c180959a..a8204783 100644 --- a/lib/Ray/include/Drawables/ADrawable2D.hpp +++ b/lib/Ray/include/Drawables/ADrawable2D.hpp @@ -19,7 +19,7 @@ namespace RAY::Drawables::Drawables2D { //! @brief ADrawable constructor //! @param poition position of top-left point //! @param Color Color of the color - ADrawable2D(const Vector2 &position, Color color); + ADrawable2D(const Vector2 &position, RAY::Color color); //! @brief ADrawable constructor //! @param x x-position of top-left point //! @param y y-position of top-left point @@ -48,7 +48,7 @@ namespace RAY::Drawables::Drawables2D { ADrawable2D &setColor(const Color &color) const; //! @brief Draw drawble on window - void drawOn(Window &); + virtual void drawOn(Window &) = 0; private: //! @brief Top-left position diff --git a/lib/Ray/include/Drawables/IDrawable.hpp b/lib/Ray/include/Drawables/IDrawable.hpp index 91d98e34..1fe63119 100644 --- a/lib/Ray/include/Drawables/IDrawable.hpp +++ b/lib/Ray/include/Drawables/IDrawable.hpp @@ -8,19 +8,20 @@ #ifndef IDRAWABLE_HPP_ #define IDRAWABLE_HPP_ -#include "Window.hpp" - -namespace RAY::Drawables +namespace RAY { - class IDrawable { - public: - virtual ~IDrawable() = 0; + class Window; + namespace Drawables { + class IDrawable { + public: + virtual ~IDrawable() = 0; - virtual void drawOn(Window &) = 0; + virtual void drawOn(RAY::Window &) = 0; - protected: - private: - }; + protected: + private: + }; + } } diff --git a/lib/Ray/src/Audio/Music.cpp b/lib/Ray/src/Audio/Music.cpp index 8f19b94a..4df87d5a 100644 --- a/lib/Ray/src/Audio/Music.cpp +++ b/lib/Ray/src/Audio/Music.cpp @@ -30,6 +30,7 @@ bool RAY::Audio::Music::load(const std::string &path) bool RAY::Audio::Music::unload(void) { UnloadMusicStream(_music); + return true; } bool RAY::Audio::Music::isPlayin(void) diff --git a/lib/Ray/src/Audio/Sound.cpp b/lib/Ray/src/Audio/Sound.cpp index 182f4808..c0c8bed7 100644 --- a/lib/Ray/src/Audio/Sound.cpp +++ b/lib/Ray/src/Audio/Sound.cpp @@ -30,6 +30,7 @@ bool RAY::Audio::Sound::load(const std::string &path) bool RAY::Audio::Sound::unload(void) { UnloadSound(_sound); + return true; } bool RAY::Audio::Sound::isPlayin(void) diff --git a/lib/Ray/src/Camera/Camera2D.cpp b/lib/Ray/src/Camera/Camera2D.cpp index 9b1aa062..b8d09416 100644 --- a/lib/Ray/src/Camera/Camera2D.cpp +++ b/lib/Ray/src/Camera/Camera2D.cpp @@ -7,7 +7,7 @@ #include "Camera/Camera2D.hpp" -RAY::Camera::Camera2D::Camera2D(const Vector2 &offset, Vector2 target, float rotation, float zoom = 1): +RAY::Camera::Camera2D::Camera2D(const Vector2 &offset, const Vector2 &target, float rotation, float zoom): _camera({offset, target, rotation, zoom}) { } diff --git a/lib/Ray/src/Camera/Camera3D.cpp b/lib/Ray/src/Camera/Camera3D.cpp index 68f14fa7..524febb0 100644 --- a/lib/Ray/src/Camera/Camera3D.cpp +++ b/lib/Ray/src/Camera/Camera3D.cpp @@ -5,9 +5,9 @@ ** Camera3D */ -#include "Camera3D.hpp" +#include "Camera/Camera3D.hpp" -RAY::Camera::Camera3D::Camera3D(const Vector3 &position, Vector3 target, Vector3 up, float fovy, float projection): +RAY::Camera::Camera3D::Camera3D(const Vector3 &position, const Vector3 &target, const Vector3 &up, float fovy, Projection projection): _camera({position, target, up, fovy, projection}) { } diff --git a/lib/Ray/src/Controllers/Gamepad.cpp b/lib/Ray/src/Controllers/Gamepad.cpp index 09f1e717..aa47b543 100644 --- a/lib/Ray/src/Controllers/Gamepad.cpp +++ b/lib/Ray/src/Controllers/Gamepad.cpp @@ -33,7 +33,7 @@ bool RAY::Controller::GamePad::isUp(RAY::Controller::GamePad::Button button) return IsGamepadButtonUp(this->_id, button); } -bool RAY::Controller::GamePad::isAvailable(RAY::Controller::GamePad::Button button) +bool RAY::Controller::GamePad::isAvailable() { return IsGamepadAvailable(this->_id); } diff --git a/lib/Ray/src/Drawables/ADrawable2D.cpp b/lib/Ray/src/Drawables/ADrawable2D.cpp new file mode 100644 index 00000000..9bb32d83 --- /dev/null +++ b/lib/Ray/src/Drawables/ADrawable2D.cpp @@ -0,0 +1,45 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** ADrawable2D +*/ + +#include "Drawables/ADrawable2D.hpp" + +RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(const Vector2 &position, RAY::Color color): + _color(color), _position(position) +{ + +} + + +RAY::Drawables::Drawables2D::ADrawable2D(int x, int y, RAY::Color color) +{ + +} + +const Vector2 &RAY::Drawables::Drawables2D::getPosition(void) const +{ + +} + +const Color &RAY::Drawables::Drawables2D::getColor(void) const +{ + +} + +ADrawable2D &RAY::Drawables::Drawables2D::setPosition(const Vector2 &position) +{ + +} + +ADrawable2D &RAY::Drawables::Drawables2D::setPosition(int x, int y) +{ + +} + +ADrawable2D &RAY::Drawables::Drawables2D::setColor(const Color &color) const +{ + +} diff --git a/lib/Ray/src/Font.cpp b/lib/Ray/src/Font.cpp index 9e303eca..3090fb9a 100644 --- a/lib/Ray/src/Font.cpp +++ b/lib/Ray/src/Font.cpp @@ -30,4 +30,5 @@ bool RAY::Font::load(const std::string &filename) bool RAY::Font::unload() { UnloadFont(this->_font); + return true; } diff --git a/lib/Ray/src/Model.cpp b/lib/Ray/src/Model.cpp index ba7ce95b..f0954df1 100644 --- a/lib/Ray/src/Model.cpp +++ b/lib/Ray/src/Model.cpp @@ -37,9 +37,11 @@ bool RAY::Model::load(const Mesh &mesh) bool RAY::Model::unload() { UnloadModel(_model); + return true; } bool RAY::Model::unloadKeepMeshes() { UnloadModelKeepMeshes(_model); + return true; } diff --git a/lib/Ray/src/Window.cpp b/lib/Ray/src/Window.cpp index 4329ae65..d8bf63fb 100644 --- a/lib/Ray/src/Window.cpp +++ b/lib/Ray/src/Window.cpp @@ -6,12 +6,12 @@ */ #include "Window.hpp" -#include "Mouse.hpp" +#include "Controllers/Mouse.hpp" RAY::Window::Window(int width, int height, const std::string title, bool openNow): - _isOpen(openNow), _dimensions({width, height}), _title(title) + _dimensions({(float)width, (float)height}), _title(title), _isOpen(openNow) { - if (this->_isOpen) + if (openNow) this->open(); } @@ -65,7 +65,7 @@ bool RAY::Window::cursorIsVisible(void) const Vector2 RAY::Window::getCursorPosition(void) const { - return RAY::Mouse::getCursorPosition(); + return RAY::Controller::Mouse::getCursorPosition(); } void RAY::Window::setFPS(unsigned int fps) @@ -113,7 +113,7 @@ void RAY::Window::setTitle(const std::string &title) this->_title = title; } -void RAY::Window::draw(Drawables::IDrawable &drawable) +void RAY::Window::draw(RAY::Drawables::IDrawable &drawable) { drawable.drawOn(*this); }