mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 08:33:36 +00:00
levitatecomponent on bonus + system + fix something in model (raylib)
This commit is contained in:
@@ -70,6 +70,10 @@ set(SOURCES
|
||||
sources/Component/Collision/CollisionComponent.hpp
|
||||
sources/System/Collision/CollisionSystem.hpp
|
||||
sources/System/Collision/CollisionSystem.cpp
|
||||
sources/System/Levitate/LevitateSystem.hpp
|
||||
sources/System/Levitate/LevitateSystem.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
)
|
||||
|
||||
add_executable(bomberman
|
||||
|
||||
@@ -80,9 +80,9 @@ namespace RAY::Drawables::Drawables3D {
|
||||
return this->_rotationAngle;
|
||||
}
|
||||
|
||||
Model &Model::setRotationAxis(const RAY::Vector3 &scale)
|
||||
Model &Model::setRotationAxis(const RAY::Vector3 &rotationAxis)
|
||||
{
|
||||
this->_scale = scale;
|
||||
this->_rotationAxis = rotationAxis;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
float getRotationAngle(void);
|
||||
|
||||
//! @brief Set Rotation Axis
|
||||
Model &setRotationAxis(const RAY::Vector3 &scale);
|
||||
Model &setRotationAxis(const RAY::Vector3 &rotationAxis);
|
||||
|
||||
//! @return rotation axis
|
||||
const RAY::Vector3 & getRotationAxis(void);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Created by hbenjamin on 07/06/2021.
|
||||
//
|
||||
|
||||
#include "LevitateComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
LevitateComponent::LevitateComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity),
|
||||
y()
|
||||
{}
|
||||
|
||||
LevitateComponent::LevitateComponent(WAL::Entity &entity, float y)
|
||||
: WAL::Component(entity),
|
||||
y(y)
|
||||
{}
|
||||
|
||||
WAL::Component *LevitateComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new LevitateComponent(entity);
|
||||
}
|
||||
|
||||
} // namespace BMM
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Created by hbenjamin on 07/06/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Models/Vector3.hpp"
|
||||
|
||||
namespace BBM {
|
||||
class LevitateComponent : public WAL::Component {
|
||||
public:
|
||||
|
||||
//! @brief Go down or up
|
||||
bool up = true;
|
||||
//! @brief Original y of the entity
|
||||
float y;
|
||||
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
//! @brief Create a new levitate component.
|
||||
explicit LevitateComponent(WAL::Entity &entity);
|
||||
|
||||
//! @brief Create a new levitate component.
|
||||
LevitateComponent(WAL::Entity &entity, float y);
|
||||
|
||||
//! @brief A Levitate component is copy constructable.
|
||||
LevitateComponent(const LevitateComponent &) = default;
|
||||
|
||||
//! @brief default destructor
|
||||
~LevitateComponent() override = default;
|
||||
|
||||
//! @brief A Levitate component can't be assigned
|
||||
LevitateComponent &operator=(const LevitateComponent &) = delete;
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <Component/Position/PositionComponent.hpp>
|
||||
#include <Component/Renderer/Drawable3DComponent.hpp>
|
||||
#include <map>
|
||||
#include <Component/Levitate/LevitateComponent.hpp>
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
#include "HealthSystem.hpp"
|
||||
#include "Component/Health/HealthComponent.hpp"
|
||||
@@ -19,7 +20,8 @@ namespace BBM
|
||||
{
|
||||
HealthSystem::HealthSystem(WAL::Wal &wal)
|
||||
: WAL::System({
|
||||
typeid(HealthComponent)
|
||||
typeid(HealthComponent),
|
||||
typeid(PositionComponent)
|
||||
}),
|
||||
_wal(wal)
|
||||
{}
|
||||
@@ -44,6 +46,7 @@ namespace BBM
|
||||
this->_wal.scene->addEntity("Bonus")
|
||||
.addComponent<PositionComponent>(position)
|
||||
.addComponent<HealthComponent>(1)
|
||||
.addComponent<LevitateComponent>(position.y)
|
||||
.addComponent<CollisionComponent>([](WAL::Entity &bonus, const WAL::Entity &player) {
|
||||
//bonus.scheduleDeletion(true);
|
||||
}, func[bonusType - 1])
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by hbenjamin on 07/06/2021.
|
||||
//
|
||||
|
||||
#include "LevitateSystem.hpp"
|
||||
|
||||
namespace BBM {
|
||||
LevitateSystem::LevitateSystem()
|
||||
: WAL::System({
|
||||
typeid(LevitateComponent),
|
||||
typeid(PositionComponent)
|
||||
})
|
||||
{}
|
||||
|
||||
void LevitateSystem::onFixedUpdate(WAL::Entity &entity) {
|
||||
auto &levitate = entity.getComponent<LevitateComponent>();
|
||||
auto &position = entity.getComponent<PositionComponent>();
|
||||
float &y = position.position.y;
|
||||
|
||||
if (levitate.up) {
|
||||
if (y < levitate.y + 0.1f)
|
||||
y += 0.004f;
|
||||
else
|
||||
levitate.up = false;
|
||||
return;
|
||||
}
|
||||
if (y > levitate.y - 0.1f)
|
||||
y -= 0.004f;
|
||||
else
|
||||
levitate.up = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by hbenjamin on 07/06/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Levitate/LevitateComponent.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "Wal.hpp"
|
||||
#include "System/System.hpp"
|
||||
|
||||
namespace BBM {
|
||||
class LevitateSystem : public WAL::System
|
||||
{
|
||||
private:
|
||||
public:
|
||||
//! @inherit
|
||||
void onFixedUpdate(WAL::Entity &entity) override;
|
||||
|
||||
//! @brief A default constructor
|
||||
LevitateSystem();
|
||||
//! @brief A Levitate system is copy constructable
|
||||
LevitateSystem(const LevitateSystem &) = default;
|
||||
//! @brief A default destructor
|
||||
~LevitateSystem() override = default;
|
||||
//! @brief A Levitate system is assignable.
|
||||
LevitateSystem &operator=(const LevitateSystem &) = default;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user