WIP
Adding models now crashes. Threading Added a create player event that currently is not used.
This commit is contained in:
+40
-18
@@ -3,24 +3,40 @@
|
||||
|
||||
void PlayerSystem::Update(World * world, ComponentWrapper & player, double dt)
|
||||
{
|
||||
if (input.Forward) {
|
||||
m_Direction.z = -1;
|
||||
} else if (input.Back) {
|
||||
m_Direction.z = 1;
|
||||
} else {
|
||||
m_Direction.z = 0;
|
||||
}
|
||||
if (input.Left) {
|
||||
m_Direction.x = -1;
|
||||
} else if (input.Right) {
|
||||
m_Direction.x = 1;
|
||||
} else {
|
||||
m_Direction.x = 0;
|
||||
}
|
||||
m_EventBroker->Process<PlayerSystem>();
|
||||
ComponentWrapper& transform = world->GetComponent(player.EntityID, "Transform");
|
||||
(glm::vec3&)player["Velocity"] = m_Speed * float(dt) * m_Direction;
|
||||
(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
|
||||
//if (player["Forward"]) {
|
||||
// ((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt) * -1;
|
||||
//}
|
||||
//if (player["Left"]) {
|
||||
// ((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt) * -1;
|
||||
//}
|
||||
//if (player["Back"]) {
|
||||
// ((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt);
|
||||
//}
|
||||
//if (player["Right"]) {
|
||||
// ((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt);
|
||||
//}
|
||||
//ComponentWrapper& transform = world->GetComponent(player.EntityID, "Transform");
|
||||
//(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
|
||||
|
||||
//m_EventBroker->Process<PlayerSystem>();
|
||||
|
||||
//// TODO Jag tror inte vi kan göra det vi vill i updaten.
|
||||
//// om man lägger till parametrar och tar bort overriden så blir det kanske inte så kul?
|
||||
//// aja, lycka till!
|
||||
//if (ShouldCreatePlayer) {
|
||||
// int entityID = world->CreateEntity();
|
||||
// ComponentWrapper transform = world->AttachComponent(entityID, "Transform");
|
||||
// transform["Position"] = glm::vec3(-1.5f, 0.f, 0.f);
|
||||
// ComponentWrapper model = world->AttachComponent(entityID, "Model");
|
||||
// model["Resource"] = "Models/Core/UnitSphere.obj";//modelPath; // You fix this :)
|
||||
// model["Color"] = glm::vec4(rand()%255 / 255.f, rand()%255 / 255.f, rand() %255 / 255.f, 1.f);
|
||||
// ShouldCreatePlayer = false;
|
||||
//}
|
||||
}
|
||||
|
||||
void PlayerSystem::CreatePlayer(World * world, unsigned int& entityID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool PlayerSystem::OnKeyDown(const Events::KeyDown & event)
|
||||
@@ -56,3 +72,9 @@ bool PlayerSystem::OnKeyUp(const Events::KeyUp & event)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlayerSystem::OnCreatePlayer(const Events::CreatePlayer & event)
|
||||
{
|
||||
ShouldCreatePlayer = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user