mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-23 23:05:10 +00:00
Merge remote-tracking branch 'origin/hole_bumper_collision' into gravity_component
This commit is contained in:
@@ -12,6 +12,28 @@ namespace RAY3D = RAY::Drawables::Drawables3D;
|
|||||||
|
|
||||||
namespace BBM
|
namespace BBM
|
||||||
{
|
{
|
||||||
|
void MapGenerator::bumperCollide(WAL::Entity &entity,
|
||||||
|
const WAL::Entity &wall,
|
||||||
|
CollisionComponent::CollidedAxis collidedAxis)
|
||||||
|
{
|
||||||
|
auto *movable = entity.tryGetComponent<MovableComponent>();
|
||||||
|
|
||||||
|
if (!movable)
|
||||||
|
return;
|
||||||
|
movable->_velocity.y = 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapGenerator::holeCollide(WAL::Entity &entity,
|
||||||
|
const WAL::Entity &wall,
|
||||||
|
CollisionComponent::CollidedAxis collidedAxis)
|
||||||
|
{
|
||||||
|
auto *health = entity.tryGetComponent<HealthComponent>();
|
||||||
|
|
||||||
|
if (!health)
|
||||||
|
return;
|
||||||
|
health->takeDmg(health->getHealthPoint());
|
||||||
|
}
|
||||||
|
|
||||||
void MapGenerator::wallCollide(WAL::Entity &entity,
|
void MapGenerator::wallCollide(WAL::Entity &entity,
|
||||||
const WAL::Entity &wall,
|
const WAL::Entity &wall,
|
||||||
CollisionComponent::CollidedAxis collidedAxis)
|
CollisionComponent::CollidedAxis collidedAxis)
|
||||||
@@ -203,19 +225,16 @@ namespace BBM
|
|||||||
|
|
||||||
WAL::Entity &holeEntity = scene->addEntity("Hole Block");
|
WAL::Entity &holeEntity = scene->addEntity("Hole Block");
|
||||||
|
|
||||||
holeEntity.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z));
|
holeEntity.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z))
|
||||||
|
.addComponent<CollisionComponent>(
|
||||||
|
WAL::Callback<WAL::Entity &, const WAL::Entity &, CollisionComponent::CollidedAxis>(),
|
||||||
|
&MapGenerator::holeCollide, Vector3f(0.25, 0.25, 0.25),Vector3f(0.75, 1.75, 0.75));
|
||||||
if (coords.y == 0)
|
if (coords.y == 0)
|
||||||
holeEntity.addComponent<Drawable3DComponent, RAY3D::Model>(holeObj, std::make_pair(MAP_DIFFUSE, holePng));
|
holeEntity.addComponent<Drawable3DComponent, RAY3D::Model>(holeObj, std::make_pair(MAP_DIFFUSE, holePng));
|
||||||
else
|
else
|
||||||
holeEntity.addComponent<Drawable3DComponent, RAY3D::Model>(secondFloorObj,
|
holeEntity.addComponent<Drawable3DComponent, RAY3D::Model>(secondFloorObj,
|
||||||
std::make_pair(MAP_DIFFUSE, secondFloorPng));
|
std::make_pair(MAP_DIFFUSE, secondFloorPng));
|
||||||
/*.addComponent<CollisionComponent>([](WAL::Entity &other, const WAL::Entity &entity) {
|
|
||||||
if (other.hasComponent<HealthComponent>()) {
|
|
||||||
auto &health = other.getComponent<HealthComponent>();
|
|
||||||
health.takeDmg(health.getHealthPoint());
|
|
||||||
}
|
|
||||||
}, [](WAL::Entity &other, const WAL::Entity &entity){}); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapGenerator::createBumper(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
void MapGenerator::createBumper(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||||
@@ -225,13 +244,10 @@ namespace BBM
|
|||||||
|
|
||||||
scene->addEntity("Bumper Block")
|
scene->addEntity("Bumper Block")
|
||||||
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y, coords.z))
|
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y, coords.z))
|
||||||
.addComponent<Drawable3DComponent, RAY3D::Model>(bumperObj, std::make_pair(MAP_DIFFUSE, bumperPng));
|
.addComponent<Drawable3DComponent, RAY3D::Model>(bumperObj, std::make_pair(MAP_DIFFUSE, bumperPng))
|
||||||
/* .addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
|
.addComponent<CollisionComponent>(
|
||||||
if (other.hasComponent<MovableComponent>()) {
|
WAL::Callback<WAL::Entity &, const WAL::Entity &, CollisionComponent::CollidedAxis>(),
|
||||||
auto &movable = other.getComponent<MovableComponent>();
|
&MapGenerator::bumperCollide, Vector3f(0.25, 0.25, 0.25),Vector3f(0.75, 0.75, 0.75));
|
||||||
movable.addForce(Vector3f(0, 5, 0));
|
|
||||||
}
|
|
||||||
}); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapGenerator::isCloseToBlockType(std::map<std::tuple<int, int, int>, BlockType> map, int x, int y, int z,
|
bool MapGenerator::isCloseToBlockType(std::map<std::tuple<int, int, int>, BlockType> map, int x, int y, int z,
|
||||||
|
|||||||
@@ -152,11 +152,22 @@ namespace BBM
|
|||||||
static const std::string secondFloorHolePath;
|
static const std::string secondFloorHolePath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void wallCollide(WAL::Entity &entity,
|
static void wallCollide(WAL::Entity &entity,
|
||||||
const WAL::Entity &wall,
|
const WAL::Entity &wall,
|
||||||
CollisionComponent::CollidedAxis collidedAxis);
|
CollisionComponent::CollidedAxis collidedAxis);
|
||||||
|
|
||||||
static void wallDestroyed(WAL::Entity &entity);
|
static void wallDestroyed(WAL::Entity &entity);
|
||||||
|
|
||||||
|
static void holeCollide(WAL::Entity &entity,
|
||||||
|
const WAL::Entity &wall,
|
||||||
|
CollisionComponent::CollidedAxis collidedAxis);
|
||||||
|
|
||||||
|
static void bumperCollide(WAL::Entity &entity,
|
||||||
|
const WAL::Entity &wall,
|
||||||
|
CollisionComponent::CollidedAxis collidedAxis);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! @param width Width of the map
|
//! @param width Width of the map
|
||||||
//! @param height Height of the map
|
//! @param height Height of the map
|
||||||
|
|||||||
Reference in New Issue
Block a user