menu scene first step

This commit is contained in:
Bluub
2021-06-03 11:53:32 +02:00
parent 36657affc6
commit c68389d1e8
4 changed files with 46 additions and 21 deletions
+2
View File
@@ -60,6 +60,8 @@ set(SOURCES
sources/Component/Collision/CollisionComponent.hpp
sources/System/Collision/CollisionSystem.hpp
sources/System/Collision/CollisionSystem.cpp
sources/Component/Button/ButtonComponent.cpp
sources/Component/Button/ButtonComponent.hpp
)
add_executable(bomberman
@@ -22,4 +22,12 @@ namespace BBM
onHover(hoverCallback),
onClick(clickCallback)
{ }
ButtonComponent::ButtonComponent(WAL::Entity &entity, std::function<void()> idleCallback,
std::function<void()> hoverCallback, std::function<void()> clickCallback)
: WAL::Component(entity),
onIdle(idleCallback),
onHover(hoverCallback),
onClick(clickCallback)
{ }
}
@@ -31,6 +31,10 @@ namespace BBM
//! @brief Constructor with the 3 callback
ButtonComponent(WAL::Entity &entity, WAL::Callback<> idleCallback, WAL::Callback<> hoverCallback, WAL::Callback<> clickCallback);
//! @brief Constructor with the 3 std functions
ButtonComponent(WAL::Entity &entity, std::function<void()> idleCallback, std::function<void()> hoverCallback, std::function<void()> clickCallback);
//! @brief A Controllable component is copy constructable.
ButtonComponent(const ButtonComponent &) = default;
//! @brief default destructor
+32 -21
View File
@@ -16,6 +16,7 @@
#include <System/Keyboard/KeyboardSystem.hpp>
#include <System/Controllable/ControllableSystem.hpp>
#include <System/Collision/CollisionSystem.hpp>
#include "Component/Button/ButtonComponent.hpp"
#include <Component/Movable/MovableComponent.hpp>
#include <Component/Collision/CollisionComponent.hpp>
#include <Component/Controllable/ControllableComponent.hpp>
@@ -67,31 +68,41 @@ namespace BBM
std::shared_ptr<WAL::Scene> loadGameScene()
{
auto scene = std::make_shared<WAL::Scene>();
scene->addEntity("player")
.addComponent<PositionComponent>()
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png"))
.addComponent<ControllableComponent>()
.addComponent<KeyboardComponent>()
.addComponent<CollisionComponent>(2)
.addComponent<MovableComponent>();
scene->addEntity("cube")
.addComponent<PositionComponent>(-5, 0, -5)
.addComponent<Drawable3DComponent<RAY3D::Cube>>(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED)
.addComponent<ControllableComponent>()
.addComponent<KeyboardComponent>()
.addComponent<CollisionComponent>([](WAL::Entity &, const WAL::Entity &){},
[](WAL::Entity &actual, const WAL::Entity &) {
try {
auto &mov = actual.getComponent<MovableComponent>();
mov.resetVelocity();
} catch (std::exception &e) { };
}, 3);
scene->addEntity("first button")
.addComponent<ButtonComponent>(
[]() {
},
[]() {
},
[]() {
}
)
.addComponent<PositionComponent>(40, 100, 0)
.addComponent<Drawable2DComponent<RAY2D::Rectangle>>(0, 0, 50, 50, RED);
scene->addEntity("second button")
.addComponent<ButtonComponent>(
[]() {
},
[]() {
},
[]() {
}
)
.addComponent<PositionComponent>(40, 200, 0)
.addComponent<Drawable2DComponent<RAY2D::Rectangle>>(0, 0, 50, 50, RED);
scene->addEntity("camera")
.addComponent<PositionComponent>(8, 20, 7)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
std::srand(std::time(NULL));
MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene);
return scene;
}