Lives kind of work, and so does the demo!

This commit is contained in:
PlatinumSkink
2015-09-15 13:35:04 +02:00
parent 9db15aa898
commit ce878ac1db
4 changed files with 51 additions and 38 deletions
+25 -21
View File
@@ -32,30 +32,34 @@ void dd::Systems::PadSystem::Initialize()
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
auto ball = m_World->GetComponent<Components::Ball>(entity);
if (replaceBall == true)
{
replaceBall = false;
if (ball != NULL) {
if (replaceBall == true) {
replaceBall = false;
//Temporary. Create new ball.
auto ent = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(0.5f, 0.f, -10.f);;
transform->Scale = glm::vec3(1.f, 1.f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
sprite->SpriteFile = "Textures/Ball.png";
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
std::shared_ptr<Components::Ball> cball = m_World->AddComponent<Components::Ball>(ent);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
physics->Static = false;
auto transformEntity = m_World->GetComponent<Components::Transform>(entity);
transformEntity->Position = glm::vec3(20, 20, -10);
m_World->RemoveEntity(entity);
m_World->CommitEntity(ent);
//Temporary. Create new ball.
auto ent = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(0.5f, 0.f, -10.f);;
transform->Scale = glm::vec3(1.f, 1.f, 1.f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
sprite->SpriteFile = "Textures/Ball.png";
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
std::shared_ptr<Components::Ball> cball = m_World->AddComponent<Components::Ball>(ent);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
physics->Static = false;
Events::SetImpulse e;
e.Entity = ent;
e.Impulse = glm::vec2(0.f, -7.f);
e.Point = glm::vec2(transform->Position.x, transform->Position.y);
EventBroker->Publish(e);
m_World->RemoveEntity(entity);
m_World->CommitEntity(ent);
Events::SetImpulse e;
e.Entity = ent;
e.Impulse = glm::vec2(0.f, -7.f);
e.Point = glm::vec2(transform->Position.x, transform->Position.y);
EventBroker->Publish(e);
}
}
}