mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-01 17:55:48 +00:00
fixed compil and finished moving files to the game
This commit is contained in:
+14
-1
@@ -5,12 +5,25 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
include_directories(bomberman lib/Ray/sources)
|
||||
include_directories(bomberman lib/wal/sources)
|
||||
include_directories(bomberman sources)
|
||||
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/lib/wal)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/lib/Ray)
|
||||
|
||||
add_executable(bomberman
|
||||
sources/main.cpp
|
||||
sources/Component/Drawable/RectangleDrawable2DComponent.cpp sources/Component/Drawable/RectangleDrawable2DComponent.hpp)
|
||||
sources/Component/Drawable/RectangleDrawable2DComponent.cpp
|
||||
sources/Component/Drawable/RectangleDrawable2DComponent.hpp
|
||||
sources/Component/Drawable/Drawable2DComponent.hpp
|
||||
sources/Component/Drawable/Drawable2DComponent.cpp
|
||||
sources/Component/Movable/MovableComponent.cpp
|
||||
sources/Component/Movable/MovableComponent.hpp
|
||||
sources/Component/Position/PositionComponent.cpp
|
||||
sources/Component/Position/PositionComponent.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/System/Renderer/RendererSystem.cpp
|
||||
sources/System/Renderer/RendererSystem.hpp
|
||||
)
|
||||
|
||||
target_link_libraries(bomberman wal ray)
|
||||
@@ -16,11 +16,9 @@ add_library(wal
|
||||
sources/Entity/Entity.cpp
|
||||
sources/Component/Component.cpp
|
||||
sources/Models/Vector3.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/System/System.cpp
|
||||
sources/Models/Callback.hpp
|
||||
sources/System/Movable/RendererSystem.cpp sources/System/Movable/RendererSystem.hpp)
|
||||
)
|
||||
|
||||
target_include_directories(wal PUBLIC sources)
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
//
|
||||
|
||||
#include "Drawable2DComponent.hpp"
|
||||
#include "Component/Component.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
Drawable2DComponent::Drawable2DComponent(WAL::Entity &entity)
|
||||
: Component(entity)
|
||||
: WAL::Component(entity),
|
||||
color(0)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,5 @@ namespace BBM
|
||||
RectangleDrawableComponent::RectangleDrawableComponent(WAL::Entity &entity)
|
||||
: Drawable2DComponent(entity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,20 @@
|
||||
//
|
||||
|
||||
#include "MovableComponent.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
MovableComponent::MovableComponent(Entity &entity)
|
||||
MovableComponent::MovableComponent(WAL::Entity &entity)
|
||||
: Component(entity)
|
||||
{}
|
||||
|
||||
Component *MovableComponent::clone(Entity &entity) const
|
||||
WAL::Component *MovableComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new MovableComponent(entity);
|
||||
}
|
||||
|
||||
void MovableComponent::addForce(Vector3f force)
|
||||
void MovableComponent::addForce(WAL::Vector3f force)
|
||||
{
|
||||
this->_acceleration += force;
|
||||
}
|
||||
|
||||
@@ -7,26 +7,26 @@
|
||||
#include "Models/Vector3.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
//! @brief A component to place on entities that can move or be moved.
|
||||
class MovableComponent : public Component
|
||||
class MovableComponent : public WAL::Component
|
||||
{
|
||||
private:
|
||||
//! @brief The acceleration of this entity.
|
||||
Vector3f _acceleration;
|
||||
WAL::Vector3f _acceleration;
|
||||
//! @brief The velocity of the entity.
|
||||
Vector3f _velocity;
|
||||
WAL::Vector3f _velocity;
|
||||
public:
|
||||
//! @brief Add an instant force to this entity.
|
||||
//! @param force The force to add to this entity's acceleration. The force is added instantly and in one go.
|
||||
void addForce(Vector3f force);
|
||||
void addForce(WAL::Vector3f force);
|
||||
|
||||
//! @inherit
|
||||
Component *clone(Entity &entity) const override;
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
//! @brief Create a new movable component.
|
||||
explicit MovableComponent(Entity &entity);
|
||||
explicit MovableComponent(WAL::Entity &entity);
|
||||
//! @brief A movable component is copy constructable.
|
||||
MovableComponent(const MovableComponent &) = default;
|
||||
//! @brief A default destructor
|
||||
|
||||
@@ -3,25 +3,27 @@
|
||||
//
|
||||
|
||||
#include "PositionComponent.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Component.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
PositionComponent::PositionComponent(Entity &entity)
|
||||
: Component(entity),
|
||||
PositionComponent::PositionComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity),
|
||||
position()
|
||||
{}
|
||||
|
||||
PositionComponent::PositionComponent(Entity &entity, Vector3f pos)
|
||||
: Component(entity),
|
||||
PositionComponent::PositionComponent(WAL::Entity &entity, WAL::Vector3f pos)
|
||||
: WAL::Component(entity),
|
||||
position(pos)
|
||||
{}
|
||||
|
||||
PositionComponent::PositionComponent(Entity &entity, float x, float y, float z)
|
||||
: Component(entity),
|
||||
PositionComponent::PositionComponent(WAL::Entity &entity, float x, float y, float z)
|
||||
: WAL::Component(entity),
|
||||
position(x, y, z)
|
||||
{}
|
||||
|
||||
Component *PositionComponent::clone(WAL::Entity &entity) const
|
||||
WAL::Component *PositionComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new PositionComponent(entity, this->position);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include "Models/Vector3.hpp"
|
||||
#include "Component/Component.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
//! @brief A basic position component
|
||||
class PositionComponent : public Component
|
||||
class PositionComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
//! @brief Get the editable position of this entity
|
||||
Vector3f position;
|
||||
WAL::Vector3f position;
|
||||
|
||||
//! @brief Get the X position of this entity.
|
||||
float getX() const;
|
||||
@@ -24,14 +24,14 @@ namespace WAL
|
||||
float getZ() const;
|
||||
|
||||
//! @inherit
|
||||
Component *clone(Entity &entity) const override;
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
//! @brief Create a new PositionComponent linked to a specific entity
|
||||
explicit PositionComponent(Entity &entity);
|
||||
explicit PositionComponent(WAL::Entity &entity);
|
||||
//! @brief Create a new PositionComponent at a certain position
|
||||
PositionComponent(Entity &entity, Vector3f pos);
|
||||
PositionComponent(WAL::Entity &entity, WAL::Vector3f pos);
|
||||
//! @brief Create a new PositionComponent at a certain position
|
||||
PositionComponent(Entity &entity, float x, float y, float z);
|
||||
PositionComponent(WAL::Entity &entity, float x, float y, float z);
|
||||
//! @brief A position component is copy constructable
|
||||
PositionComponent(const PositionComponent &) = default;
|
||||
//! @brief A default destructor
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
//
|
||||
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "System/Movable/MovableSystem.hpp"
|
||||
#include "MovableSystem.hpp"
|
||||
#include "Component/Movable/MovableComponent.hpp"
|
||||
#include "Wal.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
MovableSystem::MovableSystem()
|
||||
: System({
|
||||
: WAL::System({
|
||||
typeid(MovableComponent),
|
||||
typeid(PositionComponent)
|
||||
})
|
||||
{}
|
||||
|
||||
void MovableSystem::onFixedUpdate(Entity &entity)
|
||||
void MovableSystem::onFixedUpdate(WAL::Entity &entity)
|
||||
{
|
||||
auto &movable = entity.getComponent<MovableComponent>();
|
||||
auto &position = entity.getComponent<PositionComponent>();
|
||||
|
||||
position.position += movable._velocity * Wal::timestep.count();
|
||||
movable._velocity = movable._acceleration * Wal::timestep.count();
|
||||
movable._acceleration = Vector3f();
|
||||
position.position += movable._velocity * WAL::Wal::timestep.count();
|
||||
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
|
||||
movable._acceleration = WAL::Vector3f();
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "System/System.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
//! @brief A system to handle movable entities. This system update velocity based on accelerations and positions based on velocity.
|
||||
class MovableSystem : public System
|
||||
class MovableSystem : public WAL::System
|
||||
{
|
||||
public:
|
||||
//! @inherit
|
||||
void onFixedUpdate(Entity &entity) override;
|
||||
void onFixedUpdate(WAL::Entity &entity) override;
|
||||
|
||||
//! @brief A default constructor
|
||||
MovableSystem();
|
||||
|
||||
@@ -3,24 +3,25 @@
|
||||
//
|
||||
|
||||
#include "RendererSystem.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
|
||||
void RendererSystem::onUpdate(Entity &entity, std::chrono::nanoseconds dtime)
|
||||
void RendererSystem::onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime)
|
||||
{
|
||||
System::onUpdate(entity, dtime);
|
||||
WAL::System::onUpdate(entity, dtime);
|
||||
}
|
||||
|
||||
void RendererSystem::onFixedUpdate(Entity &entity)
|
||||
void RendererSystem::onFixedUpdate(WAL::Entity &entity)
|
||||
{
|
||||
System::onFixedUpdate(entity);
|
||||
WAL::System::onFixedUpdate(entity);
|
||||
}
|
||||
|
||||
void RendererSystem::onSelfUpdate()
|
||||
{
|
||||
System::onSelfUpdate();
|
||||
WAL::System::onSelfUpdate();
|
||||
}
|
||||
|
||||
RendererSystem::RendererSystem()
|
||||
|
||||
@@ -5,21 +5,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "System/System.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace WAL
|
||||
namespace BBM
|
||||
{
|
||||
class RendererSystem : public System
|
||||
{;
|
||||
class RendererSystem : public WAL::System
|
||||
{
|
||||
|
||||
//! @brief Update the corresponding component of the given entity
|
||||
//! @param entity The entity to update.
|
||||
//! @param dtime The delta time.
|
||||
void onUpdate(Entity &entity, std::chrono::nanoseconds dtime) override;
|
||||
void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override;
|
||||
|
||||
//! @brief An alternative of onUpdate that is called every 8ms (120 times per seconds). If the system slow down, it will try to catch up.
|
||||
//! @remark This should be used for Physics, AI and everything that could be imprecise due to float rounding.
|
||||
//! @param entity The entity to update.
|
||||
void onFixedUpdate(Entity &entity) override;
|
||||
void onFixedUpdate(WAL::Entity &entity) override;
|
||||
|
||||
//! @brief A method called after all entities that this system manage has been updated.
|
||||
void onSelfUpdate() override;
|
||||
|
||||
Reference in New Issue
Block a user