mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 08:33:36 +00:00
Add a real player death
This commit is contained in:
@@ -82,7 +82,9 @@ namespace BBM
|
||||
.addComponent<HealthComponent>(1, [](WAL::Entity &entity, WAL::Wal &) {
|
||||
auto &animation = entity.getComponent<AnimationsComponent>();
|
||||
animation.setAnimIndex(5);
|
||||
entity.addComponent<TimerComponent>(5s, [](WAL::Entity &entity, WAL::Wal &wal) {
|
||||
if (entity.hasComponent<TimerComponent>())
|
||||
return;
|
||||
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &entity, WAL::Wal &wal) {
|
||||
entity.scheduleDeletion();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "ControllableSystem.hpp"
|
||||
#include "Component/Movable/MovableComponent.hpp"
|
||||
#include "Component/Controllable/ControllableComponent.hpp"
|
||||
#include "Component/Health/HealthComponent.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace BBM
|
||||
@@ -18,8 +19,11 @@ namespace BBM
|
||||
{
|
||||
auto &controllable = entity.get<ControllableComponent>();
|
||||
auto &movable = entity.get<MovableComponent>();
|
||||
auto health = entity->tryGetComponent<HealthComponent>();
|
||||
Vector2f move = controllable.move.normalized() * controllable.speed;
|
||||
|
||||
if (health->getHealthPoint() <= 0)
|
||||
return;
|
||||
movable.addForce(Vector3f(move.x, 0, move.y));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user