Initial work on PlayerMovementSystem

This commit is contained in:
2016-01-14 17:03:42 +01:00
parent 986af01091
commit 6ad1839def
22 changed files with 146 additions and 30 deletions
+9 -1
View File
@@ -4,6 +4,11 @@
void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
{
if (!entity.HasComponent("Physics")) {
return;
}
ComponentWrapper& cPhysics = entity["Physics"];
boost::optional<AABB> boundingBox = Collision::EntityAbsoluteAABB(entity);
if (!boundingBox) {
return;
@@ -25,7 +30,10 @@ void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, Compo
continue;
}
if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
(glm::vec3&)cTransform["Position"] += resolutionVector;
if (entity.HasComponent("Physics")) {
(glm::vec3&)cTransform["Position"] += resolutionVector;
cPhysics["Velocity"] = glm::vec3(0, 0, 0);
}
}
}
+4 -5
View File
@@ -11,16 +11,15 @@ include_directories(
)
file(GLOB SOURCE_FILES
"${INCLUDE_PATH}/*.h"
#"*.cpp"
"${INCLUDE_PATH}/Systems/*.h"
"Systems/*.cpp"
)
#source_group(Core FILES ${SOURCE_FILES})
source_group(Systems FILES ${SOURCE_FILES_Systems})
set(SOURCE_FILES
${SOURCE_FILES}
"Game.cpp"
"HealthSystem.cpp"
"PlayerSystem.cpp"
${SOURCE_FILES_Systems}
)
set(LIBRARIES
+5 -1
View File
@@ -2,7 +2,10 @@
#include "Collision/CollidableOctreeSystem.h"
#include "Collision/TriggerSystem.h"
#include "Collision/CollisionSystem.h"
#include "Game/HealthSystem.h"
#include "Systems/RaptorCopterSystem.h"
#include "Systems/PlayerSystem.h"
#include "Systems/HealthSystem.h"
#include "Systems/PlayerMovementSystem.h"
#include "Core/EntityFileWriter.h"
Game::Game(int argc, char* argv[])
@@ -69,6 +72,7 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<PlayerSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
// Populate Octree with collidables
++updateOrderLevel;
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
-6
View File
@@ -1,6 +0,0 @@
#include "RaptorCopterSystem.h"
void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
{
ComponentWrapper& transform = world->GetComponent(component.EntityID);
}
@@ -1,5 +1,4 @@
#include "HealthSystem.h"
#include <algorithm>
#include "Systems/HealthSystem.h"
HealthSystem::HealthSystem(EventBroker* eventBroker)
: System(eventBroker)
+16
View File
@@ -0,0 +1,16 @@
#include "Systems/PlayerMovementSystem.h"
void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
{
ComponentWrapper& cTransform = entity["Transform"];
if (!entity.HasComponent("Physics")) {
return;
}
ComponentWrapper& cPhysics = entity["Physics"];
glm::vec3& velocity = cPhysics["Velocity"];
velocity.y -= 9.82 * dt;
glm::vec3& position = cTransform["Position"];
position += velocity * (float)dt;
}
@@ -1,4 +1,4 @@
#include "PlayerSystem.h"
#include "Systems/PlayerSystem.h"
void PlayerSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
{