Merge branch 'LevelSystemAndSuch'
This commit is contained in:
@@ -24,6 +24,8 @@ struct Ball : Component
|
|||||||
bool Sticky = false;
|
bool Sticky = false;
|
||||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||||
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
||||||
|
|
||||||
|
int PosterBoy = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ struct Brick : Component
|
|||||||
int Type = 0;
|
int Type = 0;
|
||||||
bool Removed = false;
|
bool Removed = false;
|
||||||
int Number = 100; // For the Kraken to keep track of which bricks needs replacing.
|
int Number = 100; // For the Kraken to keep track of which bricks needs replacing.
|
||||||
|
bool BeingGenerated = false;
|
||||||
|
glm::vec3 GenerationGoal;
|
||||||
|
|
||||||
//What number of types each is.
|
//What number of types each is.
|
||||||
const int EmptyBrickSpace = 0;
|
const int EmptyBrickSpace = 0;
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ namespace dd
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Life : Component {
|
struct Life : Component
|
||||||
|
{
|
||||||
int Number = 0;
|
int Number = 0;
|
||||||
|
float SinusAltitude = 1;
|
||||||
|
bool Left = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ private:
|
|||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
int m_Lives = 3;
|
int m_Lives = 3;
|
||||||
int m_PastLives = 3;
|
int m_PastLives = 3;
|
||||||
|
float m_LifeSpeed = 0.8;
|
||||||
|
|
||||||
bool m_GodMode = false;
|
bool m_GodMode = false;
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
||||||
transform2->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
transform2->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||||
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.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);
|
SetReplaceBall(true);
|
||||||
@@ -88,6 +95,11 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
if (templateCheck != nullptr){ return; }
|
if (templateCheck != nullptr){ return; }
|
||||||
|
|
||||||
if (ballComponent != nullptr) {
|
if (ballComponent != nullptr) {
|
||||||
|
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
if (ballComponent->PosterBoy == 1) {
|
||||||
|
transformBall->Position = glm::vec3(-3, 3, -10);
|
||||||
|
}
|
||||||
|
|
||||||
if (ReplaceBall()) {
|
if (ReplaceBall()) {
|
||||||
m_First = true;
|
m_First = true;
|
||||||
SetReplaceBall(false);
|
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(random, 1, 0.f);
|
||||||
//ballComponent->SavedSpeed = glm::vec3(0.f, 1, 0.f);
|
//ballComponent->SavedSpeed = glm::vec3(0.f, 1, 0.f);
|
||||||
ballComponent->Waiting = true;
|
ballComponent->Waiting = true;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ballComponent->Waiting) {
|
if (ballComponent->Waiting) {
|
||||||
if (!m_Waiting) {
|
if (!m_Waiting) {
|
||||||
m_Restarting = false;
|
m_Restarting = false;
|
||||||
ballComponent->Waiting = false;
|
ballComponent->Waiting = false;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
|
||||||
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
||||||
float random = dist(m_RandomGenerator);*/
|
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;
|
//transform->Velocity = glm::normalize(glm::vec3(0, 1, 0)) * ballComponent->Speed;
|
||||||
} else if (!ballComponent->Sticky) {
|
} else if (!ballComponent->Sticky) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
transformBall->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
|
||||||
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||||
if (m_First) {
|
if (m_First) {
|
||||||
transform->Orientation = glm::quat();
|
transformBall->Orientation = glm::quat();
|
||||||
m_First = false;
|
m_First = false;
|
||||||
}
|
}
|
||||||
return;
|
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.
|
//TODO - Ball can stick to same pad just after detaching.
|
||||||
if (!m_Waiting)
|
if (!m_Waiting)
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
transformBall->Velocity = ballComponent->SavedSpeed;
|
||||||
transform->Velocity = ballComponent->SavedSpeed;
|
|
||||||
m_StickyCounter--;
|
m_StickyCounter--;
|
||||||
if (m_StickyCounter > 0) {
|
if (m_StickyCounter > 0) {
|
||||||
m_Sticky = true;
|
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 (glm::abs(transformBall->Velocity.y) < 2) {
|
||||||
if (transformBall->Velocity.y > 0) {
|
if (transformBall->Velocity.y > 0) {
|
||||||
transformBall->Velocity.y = 2;
|
transformBall->Velocity.y = 2;
|
||||||
|
|||||||
@@ -281,7 +281,19 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||||
if (brick != nullptr) {
|
if (brick != nullptr) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
if (brick->BeingGenerated) {
|
||||||
|
if (transform->Position == brick->GenerationGoal) {
|
||||||
|
brick->BeingGenerated = false;
|
||||||
|
auto cPhys = m_World->AddComponent<Components::Physics>(entity);
|
||||||
|
cPhys->CollisionType = CollisionType::Type::Static;
|
||||||
|
cPhys->GravityScale = 0.f;
|
||||||
|
cPhys->Category = CollisionLayer::Type::Brick;
|
||||||
|
cPhys->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Removes bricks that falls out of the stage.
|
//Removes bricks that falls out of the stage.
|
||||||
if (transform->Position.y < -10) {
|
if (transform->Position.y < -10) {
|
||||||
if (brick->Type == StandardBrick) {
|
if (brick->Type == StandardBrick) {
|
||||||
@@ -481,6 +493,8 @@ bool dd::Systems::LevelSystem::BrickGenerating(const dd::Events::BrickGenerating
|
|||||||
auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -3.2, 1, m_BrickSet[getter], m_ColorSet[getter]);
|
auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -3.2, 1, m_BrickSet[getter], m_ColorSet[getter]);
|
||||||
if (ent != NULL) {
|
if (ent != NULL) {
|
||||||
auto brick = m_World->GetComponent<Components::Brick>(ent);
|
auto brick = m_World->GetComponent<Components::Brick>(ent);
|
||||||
|
brick->BeingGenerated = true;
|
||||||
|
m_World->RemoveComponent<Components::Physics>(ent);
|
||||||
brick->Number = getter;
|
brick->Number = getter;
|
||||||
m_KrakenBricks[getter] = true;
|
m_KrakenBricks[getter] = true;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||||
@@ -491,6 +505,7 @@ bool dd::Systems::LevelSystem::BrickGenerating(const dd::Events::BrickGenerating
|
|||||||
} else {
|
} else {
|
||||||
transform->Position = event.Origin2;
|
transform->Position = event.Origin2;
|
||||||
}
|
}
|
||||||
|
brick->GenerationGoal = e.GoalPosition;
|
||||||
e.Entity = ent;
|
e.Entity = ent;
|
||||||
e.Speed = 6;
|
e.Speed = 6;
|
||||||
e.Queue = false;
|
e.Queue = false;
|
||||||
@@ -690,7 +705,11 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
brick = m_World->GetComponent<Components::Brick>(entityBrick);
|
brick = m_World->GetComponent<Components::Brick>(entityBrick);
|
||||||
if (brick == nullptr) {
|
if (brick == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (brick->BeingGenerated) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (entityShot != 0) {
|
if (entityShot != 0) {
|
||||||
// For when a brick gets shot.
|
// For when a brick gets shot.
|
||||||
@@ -1102,7 +1121,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
|||||||
1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 0, 1, 2, 1, 0, 1,
|
1, 0, 1, 2, 1, 0, 1,
|
||||||
0, 1, 0, 1, 0, 1, 0,
|
0, 1, 0, 1, 0, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 6,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0};
|
0, 0, 0, 0, 0, 0, 0};
|
||||||
color =
|
color =
|
||||||
{w, w, w, w, w, w, w,
|
{w, w, w, w, w, w, w,
|
||||||
|
|||||||
@@ -47,10 +47,29 @@ void dd::Systems::LifeSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
if (templateCheck != nullptr){ return; }
|
if (templateCheck != nullptr){ return; }
|
||||||
|
auto life = m_World->GetComponent<Components::Life>(entity);
|
||||||
|
|
||||||
if (Lives() != PastLives()) {
|
|
||||||
auto life = m_World->GetComponent<Components::Life>(entity);
|
if (life != nullptr) {
|
||||||
if (life != nullptr) {
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
if (life->Left) {
|
||||||
|
if (transform->Position.x > 3) {
|
||||||
|
life->Left = false;
|
||||||
|
transform->Velocity.x = m_LifeSpeed;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (transform->Position.x < -3) {
|
||||||
|
life->Left = true;
|
||||||
|
transform->Velocity.x = -m_LifeSpeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transform->Position.x += transform->Velocity.x * dt;
|
||||||
|
/*glm::vec2 dir = glm::normalize(glm::vec2(transform->Velocity.x, transform->Velocity.y));
|
||||||
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
|
transform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));*/
|
||||||
|
if (Lives() != PastLives()) {
|
||||||
if (life->Number + 1 == PastLives()) {
|
if (life->Number + 1 == PastLives()) {
|
||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
SetPastLives(Lives());
|
SetPastLives(Lives());
|
||||||
@@ -64,7 +83,9 @@ void dd::Systems::LifeSystem::CreateLife(int number)
|
|||||||
auto life = m_World->CreateEntity();
|
auto life = m_World->CreateEntity();
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
||||||
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
||||||
|
//transform->Position = glm::vec3(-1.5f + number * 1.5f, -3.f, -10.f);
|
||||||
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||||
|
//transform->Scale = glm::vec3(0.2f, 0.2f, 0.2f);
|
||||||
|
|
||||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||||
lifeNr->Number = number;
|
lifeNr->Number = number;
|
||||||
@@ -83,7 +104,7 @@ bool dd::Systems::LifeSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
|||||||
SetLives(Lives() - 1);
|
SetLives(Lives() - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::LifeSystem::OnPause(const dd::Events::Pause &event)
|
bool dd::Systems::LifeSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
|||||||
Reference in New Issue
Block a user