mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-06 19:22:20 +00:00
fix namespaces + assets
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by cbihan on 24/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class Drawable2DComponent : public WAL::Component, public T
|
||||
{
|
||||
public:
|
||||
|
||||
explicit Drawable2DComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity)
|
||||
{
|
||||
}
|
||||
|
||||
WAL::Component *clone(WAL::Entity &entity) const override
|
||||
{
|
||||
return new Drawable2DComponent(entity);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by cbihan on 24/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class Drawable3DComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
T member;
|
||||
|
||||
explicit Drawable3DComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity)
|
||||
{
|
||||
}
|
||||
|
||||
WAL::Component *clone(WAL::Entity &entity) const override
|
||||
{
|
||||
return new Drawable3DComponent(entity);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// Created by cbihan on 24/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
#include "Color.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class DrawableComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
T member;
|
||||
|
||||
explicit DrawableComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -36,4 +36,4 @@ namespace BBM
|
||||
|
||||
friend class MovableSystem;
|
||||
};
|
||||
}
|
||||
} // namespace WAL
|
||||
@@ -39,4 +39,4 @@ namespace BBM
|
||||
//! @brief A position component is not assignable
|
||||
PositionComponent &operator=(const PositionComponent &) = delete;
|
||||
};
|
||||
}
|
||||
} // namespace WAL
|
||||
@@ -25,4 +25,4 @@ namespace BBM
|
||||
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
|
||||
movable._acceleration = WAL::Vector3f();
|
||||
}
|
||||
}
|
||||
} // namespace WAL
|
||||
@@ -26,4 +26,4 @@ class MovableSystem : public WAL::System
|
||||
//! @brief A movable system is assignable.
|
||||
MovableSystem &operator=(const MovableSystem &) = default;
|
||||
};
|
||||
}
|
||||
} // namespace WAL
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by cbihan on 24/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include "System/System.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "Component/Drawable/Drawable2DComponent.hpp"
|
||||
#include "Window.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class Renderer2DSystem : public WAL::System
|
||||
{
|
||||
private:
|
||||
//! @brief The class to render
|
||||
RAY::Window &_window;
|
||||
public:
|
||||
explicit Renderer2DSystem(RAY::Window &window)
|
||||
: WAL::System({typeid(PositionComponent), typeid(Drawable2DComponent<T>)}),
|
||||
_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override
|
||||
{
|
||||
auto &comp = entity.getComponent<Drawable2DComponent<T>>();
|
||||
auto &pos = entity.getComponent<PositionComponent>();
|
||||
|
||||
comp.setPosition({pos.getX(), pos.getY()});
|
||||
comp.drawOn(this->_window);
|
||||
}
|
||||
|
||||
Renderer2DSystem(const Renderer2DSystem &) = default;
|
||||
~Renderer2DSystem() override = default;
|
||||
Renderer2DSystem &operator=(const Renderer2DSystem &) = delete;
|
||||
};
|
||||
}
|
||||
+9
-9
@@ -8,35 +8,35 @@
|
||||
#include "System/System.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "Component/Drawable/DrawableComponent.hpp"
|
||||
#include "Component/Drawable/Drawable3DComponent.hpp"
|
||||
#include "Window.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
template <class T>
|
||||
class RendererSystem : public WAL::System
|
||||
class Renderer3DSystem : public WAL::System
|
||||
{
|
||||
private:
|
||||
//! @brief The class to render
|
||||
RAY::Window &_window;
|
||||
public:
|
||||
explicit RendererSystem(RAY::Window &window)
|
||||
: WAL::System({typeid(PositionComponent), typeid(DrawableComponent<T>)}),
|
||||
explicit Renderer3DSystem(RAY::Window &window)
|
||||
: WAL::System({typeid(PositionComponent), typeid(Drawable3DComponent<T>)}),
|
||||
_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override
|
||||
{
|
||||
auto &comp = entity.getComponent<DrawableComponent<T>>();
|
||||
auto &comp = entity.getComponent<Drawable3DComponent<T>>();
|
||||
auto &pos = entity.getComponent<PositionComponent>();
|
||||
|
||||
// TODO update drawable pos with pos
|
||||
comp.member.setPosition(pos);
|
||||
comp.member.drawOn(this->_window);
|
||||
}
|
||||
|
||||
RendererSystem(const RendererSystem &) = default;
|
||||
~RendererSystem() override = default;
|
||||
RendererSystem &operator=(const RendererSystem &) = delete;
|
||||
Renderer3DSystem(const Renderer3DSystem &) = default;
|
||||
~Renderer3DSystem() override = default;
|
||||
Renderer3DSystem &operator=(const Renderer3DSystem &) = delete;
|
||||
};
|
||||
}
|
||||
+4
-1
@@ -13,8 +13,11 @@
|
||||
#include "Drawables/Image.hpp"
|
||||
#include "Drawables/3D/Grid.hpp"
|
||||
#include "Drawables/Texture.hpp"
|
||||
#include "Drawables/2D/Circle.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
#include "Model/ModelAnimations.hpp"
|
||||
#include "System/Renderer/Renderer2DSystem.hpp"
|
||||
#include "Component/Drawable/Drawable2DComponent.hpp"
|
||||
#include "Vector/Vector3.hpp"
|
||||
#include "Window.hpp"
|
||||
#include "TraceLog.hpp"
|
||||
@@ -46,7 +49,7 @@ int main()
|
||||
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE);
|
||||
RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f),
|
||||
RAY::Vector3(0.0f, 0.0f, 0.0f),
|
||||
RAY::Vector3(0.0f, 1.0f, 0.0f),
|
||||
RAY::Vector3(0.0f, 1.0f, 0.0f),
|
||||
45.0f, CAMERA_PERSPECTIVE
|
||||
);
|
||||
RAY::Model model(modelPath);
|
||||
|
||||
Reference in New Issue
Block a user