Fixed so generated bricks fo not collide with anything.
This commit is contained in:
@@ -64,6 +64,13 @@ void dd::Systems::BallSystem::Initialize()
|
||||
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
||||
transform2->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||
|
||||
/*auto PosterBoy = CreateBall();
|
||||
auto PosterBall = m_World->GetComponent<Components::Ball>(PosterBoy);
|
||||
PosterBall->PosterBoy = 1;
|
||||
auto Postertran = m_World->GetComponent<Components::Transform>(PosterBoy);
|
||||
Postertran->Position = glm::vec3(-3.f, -3.f, -10.f);
|
||||
Postertran->Velocity = glm::vec3(0.0f, 0.f, 0.f);*/
|
||||
}
|
||||
|
||||
SetReplaceBall(true);
|
||||
@@ -88,6 +95,11 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
if (ballComponent != nullptr) {
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (ballComponent->PosterBoy == 1) {
|
||||
transformBall->Position = glm::vec3(-3, 3, -10);
|
||||
}
|
||||
|
||||
if (ReplaceBall()) {
|
||||
m_First = true;
|
||||
SetReplaceBall(false);
|
||||
@@ -97,24 +109,21 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
ballComponent->SavedSpeed = glm::vec3(random, 1, 0.f);
|
||||
//ballComponent->SavedSpeed = glm::vec3(0.f, 1, 0.f);
|
||||
ballComponent->Waiting = true;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
}
|
||||
|
||||
if (ballComponent->Waiting) {
|
||||
if (!m_Waiting) {
|
||||
m_Restarting = false;
|
||||
ballComponent->Waiting = false;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
||||
float random = dist(m_RandomGenerator);*/
|
||||
transform->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
|
||||
transformBall->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
|
||||
//transform->Velocity = glm::normalize(glm::vec3(0, 1, 0)) * ballComponent->Speed;
|
||||
} else if (!ballComponent->Sticky) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
transformBall->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||
if (m_First) {
|
||||
transform->Orientation = glm::quat();
|
||||
transformBall->Orientation = glm::quat();
|
||||
m_First = false;
|
||||
}
|
||||
return;
|
||||
@@ -124,8 +133,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
//TODO - Ball can stick to same pad just after detaching.
|
||||
if (!m_Waiting)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = ballComponent->SavedSpeed;
|
||||
transformBall->Velocity = ballComponent->SavedSpeed;
|
||||
m_StickyCounter--;
|
||||
if (m_StickyCounter > 0) {
|
||||
m_Sticky = true;
|
||||
@@ -134,7 +142,6 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
}
|
||||
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (glm::abs(transformBall->Velocity.y) < 2) {
|
||||
if (transformBall->Velocity.y > 0) {
|
||||
transformBall->Velocity.y = 2;
|
||||
|
||||
Reference in New Issue
Block a user