diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-27 17:12:49 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:53 +0200 |
commit | fe79577396231f2edb7927f1f61ce814f03851a7 (patch) | |
tree | d353a1caa449ec772dcf9a8681084fc2d6e64116 /src/interfaces | |
parent | 6964d48c970e5f7b11897096c816271785af23ac (diff) |
add basic engine graphics
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/bounds.hpp | 41 | ||||
-rw-r--r-- | src/interfaces/matrix.hpp | 48 | ||||
-rw-r--r-- | src/interfaces/scene.hpp | 15 |
3 files changed, 104 insertions, 0 deletions
diff --git a/src/interfaces/bounds.hpp b/src/interfaces/bounds.hpp new file mode 100644 index 0000000..9cec97e --- /dev/null +++ b/src/interfaces/bounds.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include "interfaces/vector2.hpp" + +#include <functional> +#include <memory> + +enum CoordsValidation +{ + VALID, + X_HIGH, + Y_HIGH +}; + +class IBounds +{ +public: + [[nodiscard]] virtual unsigned int width() const = 0; + + virtual void width(unsigned int width) = 0; + + [[nodiscard]] virtual unsigned int height() const = 0; + + virtual void height(unsigned int height) = 0; + + [[nodiscard]] virtual CoordsValidation + validate_coords(const IVector2 &coords) const = 0; + + virtual const IBounds &operator*=(const IBounds &bounds) = 0; + virtual const IBounds &operator+=(const IBounds &bounds) = 0; + virtual const IBounds &operator-=(const IBounds &bounds) = 0; +}; + +struct IBoundsOptions +{ + unsigned int width; + unsigned int height; +}; + +using IBoundsFactory = + std::function<std::shared_ptr<IBounds>(const IBoundsOptions &options)>; diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp new file mode 100644 index 0000000..5dc5f2e --- /dev/null +++ b/src/interfaces/matrix.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include "interfaces/bounds.hpp" +#include "interfaces/vector2.hpp" + +#include <functional> +#include <memory> + +template <typename Element> +class IMatrix +{ +public: + /** + * Fills the matrix with a element. + * + * @param element A element + */ + virtual void fill(Element element) = 0; + + /** + * Returns a element of the matrix. + * + * @param pos The position of a element + */ + [[nodiscard]] virtual Element get(const IVector2 &pos) const = 0; + + /** + * Sets a element of the matrix. + * + * @param pos The position of a element + * @param element A new element + */ + virtual void set(const IVector2 &pos, Element element) = 0; + + /** + * Returns the number of rows the matrix has. + */ + [[nodiscard]] virtual unsigned int rows() const = 0; + + /** + * Returns the number of columns the matrix has. + */ + [[nodiscard]] virtual unsigned int columns() const = 0; +}; + +template <typename Element> +using IMatrixFactory = + std::function<std::shared_ptr<IMatrix<Element>>(const IBounds &bounds)>; diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp new file mode 100644 index 0000000..8b34dae --- /dev/null +++ b/src/interfaces/scene.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "interfaces/matrix.hpp" + +#include <functional> +#include <memory> +#include <string_view> + +class IScene +{ +public: + virtual void enter() = 0; + + virtual void leave() = 0; +}; |