(NDK) Added Velocity component/system

Former-commit-id: 427b7175fbf9723fcd1d54fc279b8b70167745d4
This commit is contained in:
Lynix
2015-04-12 23:19:53 +02:00
parent 2ab0defa48
commit ead468525e
8 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Systems/VelocitySystem.hpp>
#include <NDK/Components/NodeComponent.hpp>
#include <NDK/Components/VelocityComponent.hpp>
namespace Ndk
{
VelocitySystem::VelocitySystem()
{
Requires<NodeComponent, VelocityComponent>();
}
void VelocitySystem::Update(float elapsedTime)
{
for (const Ndk::EntityHandle& entity : GetEntities())
{
NodeComponent& node = entity->GetComponent<NodeComponent>();
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
node.Move(velocity.linearVelocity * elapsedTime);
}
}
SystemIndex VelocitySystem::systemIndex;
}