mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 13:55:10 +00:00
change window draw function to IDrawable
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include "Vector/Vector2.hpp"
|
||||
#include "Image.hpp"
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
#include "Color.hpp"
|
||||
|
||||
|
||||
@@ -8,20 +8,18 @@
|
||||
#ifndef IDRAWABLE_HPP_
|
||||
#define IDRAWABLE_HPP_
|
||||
|
||||
#include "Drawables/Image.hpp"
|
||||
#include "Window.hpp"
|
||||
|
||||
namespace RAY
|
||||
{
|
||||
class Window;
|
||||
class Image;
|
||||
namespace Drawables {
|
||||
//! @brief Interface for any drawable
|
||||
class IDrawable {
|
||||
public:
|
||||
virtual ~IDrawable() = default;
|
||||
|
||||
virtual void drawOn(RAY::Window &) = 0;
|
||||
virtual void drawOn(Window &) = 0;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -146,12 +146,7 @@ void RAY::Window::setTitle(const std::string &title)
|
||||
this->_title = title;
|
||||
}
|
||||
|
||||
void RAY::Window::draw(RAY::Drawables::ADrawable2D &drawable)
|
||||
{
|
||||
drawable.drawOn(*this);
|
||||
}
|
||||
|
||||
void RAY::Window::draw(RAY::Drawables::ADrawable3D &drawable)
|
||||
void RAY::Window::draw(RAY::Drawables::IDrawable &drawable)
|
||||
{
|
||||
drawable.drawOn(*this);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include <string>
|
||||
#include "Drawables/Image.hpp"
|
||||
#include "Vector/Vector2.hpp"
|
||||
#include "Vector/Vector3.hpp"
|
||||
#include "Controllers/Keyboard.hpp"
|
||||
@@ -18,11 +19,13 @@
|
||||
#include "Color.hpp"
|
||||
#include "Drawables/Texture.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
|
||||
namespace RAY {
|
||||
class Model;
|
||||
//! @brief Window manager
|
||||
namespace Drawables {
|
||||
class IDrawable;
|
||||
class ADrawable3D;
|
||||
}
|
||||
class Window {
|
||||
@@ -66,7 +69,7 @@ namespace RAY {
|
||||
bool cursorIsVisible(void) const;
|
||||
|
||||
//! @brief set the window icon
|
||||
void setIcon(Image &img);
|
||||
void setIcon(RAY::Image &img);
|
||||
|
||||
//! @brief Get the cursor position
|
||||
Vector2 getCursorPosition() const;
|
||||
@@ -114,11 +117,7 @@ namespace RAY {
|
||||
|
||||
//! @brief draw drawable
|
||||
//! @param drawable The drawable to render on screen
|
||||
void draw(RAY::Drawables::ADrawable2D &drawable);
|
||||
|
||||
//! @brief draw drawable
|
||||
//! @param drawable The drawable to render on screen
|
||||
void draw(RAY::Drawables::ADrawable3D &drawable);
|
||||
void draw(RAY::Drawables::IDrawable &drawable);
|
||||
|
||||
//! @brief draw texture at position
|
||||
//! @param texture The object to render
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace WAL
|
||||
|
||||
void Wal::_update(std::chrono::nanoseconds dtime)
|
||||
{
|
||||
auto &entities = this->_scene.getEntities();
|
||||
auto &entities = this->scene.getEntities();
|
||||
|
||||
for (auto &system : this->_systems) {
|
||||
for (auto &entity : entities) {
|
||||
@@ -26,7 +26,7 @@ namespace WAL
|
||||
|
||||
void Wal::_fixedUpdate()
|
||||
{
|
||||
auto &entities = this->_scene.getEntities();
|
||||
auto &entities = this->scene.getEntities();
|
||||
|
||||
for (auto &system : this->_systems) {
|
||||
for (auto &entity : entities) {
|
||||
|
||||
@@ -20,9 +20,7 @@ namespace WAL
|
||||
//! @brief The main WAL class, it is used to setup and run the ECS.
|
||||
class Wal
|
||||
{
|
||||
public:
|
||||
//! @brief The scene manager that allow multiple scene to work together.
|
||||
Scene _scene;
|
||||
private:
|
||||
//! @brief The list of registered systems
|
||||
std::vector<std::unique_ptr<System>> _systems = {};
|
||||
//! @brief True if the engine should close after the end of the current tick.
|
||||
@@ -40,6 +38,8 @@ namespace WAL
|
||||
//! @return True if all dependencies are met, false otherwise.
|
||||
static bool _hasDependencies(const Entity &entity, const System &system);
|
||||
public:
|
||||
//! @brief The scene manager that allow multiple scene to work together.
|
||||
Scene scene;
|
||||
//! @brief The time between each fixed update.
|
||||
static std::chrono::nanoseconds timestep;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ int demo()
|
||||
entityPlayer.addComponent(circleComponent);
|
||||
entityPlayer.addComponent(cubeComponent);
|
||||
entityPlayer.addComponent(posComponent);
|
||||
wal._scene.addEntity(entityPlayer);
|
||||
wal.scene.addEntity(entityPlayer);
|
||||
|
||||
camera.setMode(CAMERA_FREE); // Set free camera mode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user