Merge remote-tracking branch 'origin/master' into Physics
This commit is contained in:
@@ -20,6 +20,7 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||
|
||||
@@ -115,19 +116,10 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
|
||||
if (ballComponent->Waiting) {
|
||||
if (m_Waiting == false) {
|
||||
if (!m_Waiting) {
|
||||
ballComponent->Waiting = false;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||
if (ballComponent->Sticky) {
|
||||
transform->Velocity = ballComponent->SavedSpeed;
|
||||
m_StickyCounter--;
|
||||
std::cout << m_StickyCounter << std::endl;
|
||||
if (m_StickyCounter > 0) {
|
||||
m_Sticky = true;
|
||||
}
|
||||
ballComponent->Sticky = false;
|
||||
}
|
||||
} else if (!ballComponent->Sticky) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
@@ -136,6 +128,18 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ballComponent->Sticky) {
|
||||
if (!m_Waiting)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = ballComponent->SavedSpeed;
|
||||
m_StickyCounter--;
|
||||
if (m_StickyCounter > 0) {
|
||||
m_Sticky = true;
|
||||
}
|
||||
ballComponent->Sticky = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (glm::abs(transformBall->Velocity.y) < 2) {
|
||||
@@ -279,15 +283,19 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
ballComponent->Combo = 0;
|
||||
|
||||
if (m_InkBlaster) {
|
||||
m_InkBlaster = false;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
if (!m_InkAttached) {
|
||||
m_InkAttached = true;
|
||||
m_Waiting = true;
|
||||
m_BlockedWaiting = true;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
}
|
||||
} else if (m_Sticky) {
|
||||
m_Sticky = false;
|
||||
m_Waiting = true;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->Waiting = true;
|
||||
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity *= -1;
|
||||
@@ -439,9 +447,26 @@ bool dd::Systems::BallSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver &event)
|
||||
{
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(event.Ball);
|
||||
|
||||
m_InkBlaster = false;
|
||||
m_InkAttached = false;
|
||||
m_BlockedWaiting = false;
|
||||
m_Sticky = true;
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
||||
m_Waiting = false;
|
||||
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
m_Waiting = false;
|
||||
if (!m_BlockedWaiting) {
|
||||
m_Waiting = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+117
-14
@@ -150,7 +150,7 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
||||
for (int i = 0; i < rows; i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, 0, num, 1);
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, 0, num, 1, glm::vec4(0, 0, 0, 0));
|
||||
}
|
||||
if (num == 1)
|
||||
num = Lines();
|
||||
@@ -171,7 +171,7 @@ void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel)
|
||||
for (int i = 0; i < Rows(); i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), aboveBasicLevel, num, m_Bricks[getter]);
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), aboveBasicLevel, num, m_Bricks[getter], m_Colors[getter]);
|
||||
getter++;
|
||||
}
|
||||
if (num == 1) {
|
||||
@@ -182,7 +182,7 @@ void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel)
|
||||
SetRestarting(false);
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt)
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt, glm::vec4 colorVec)
|
||||
{
|
||||
if (typeInt == EmptyBrickSpace) {
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
@@ -192,25 +192,24 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
m_World->RemoveComponent<Components::Template>(brick);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(brick);
|
||||
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
if (typeInt == StandardBrick) {
|
||||
model->Color = colorVec;
|
||||
} else if (typeInt == MultiBallBrick) {
|
||||
cBrick->Type = MultiBallBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->ModelFile = "Models/Brick/IceBrick.obj";
|
||||
} else if (typeInt == LifebuoyBrick) {
|
||||
cBrick->Type = LifebuoyBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->ModelFile = "Models/Brick/LifeBuoyBrick.obj";
|
||||
} else if (typeInt == StickyBrick) {
|
||||
cBrick->Type = StickyBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->ModelFile = "Models/Brick/StickyBrick.obj";
|
||||
} else if (typeInt == InkBlasterBrick) {
|
||||
cBrick->Type = InkBlasterBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, .0f);
|
||||
}
|
||||
|
||||
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
|
||||
@@ -225,7 +224,6 @@ void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
||||
|
||||
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
LOG_DEBUG("Collision happened!");
|
||||
EntityID entityBrick;
|
||||
EntityID entityBall;
|
||||
EntityID entityShot = 0;
|
||||
@@ -250,12 +248,10 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
} else {
|
||||
auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
|
||||
if (shot != nullptr) {
|
||||
LOG_DEBUG("Entity1 is a shot!");
|
||||
entityShot = event.Entity1;
|
||||
} else {
|
||||
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
|
||||
if (shot != nullptr) {
|
||||
LOG_DEBUG("Entity2 is a shot!");
|
||||
entityShot = event.Entity2;
|
||||
} else {
|
||||
return false;
|
||||
@@ -319,6 +315,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
|
||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
auto transformComponentBall = m_World->GetComponent<Components::Transform>(entityBall);
|
||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
||||
|
||||
Events::SetImpulse e;
|
||||
e.Entity = entityBrick;
|
||||
@@ -337,6 +334,21 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
es.Score = brick->Score * ball->Combo;
|
||||
EventBroker->Publish(es);
|
||||
|
||||
Events::CreateParticleSequence ep;
|
||||
ep.parent = entityBrick;
|
||||
ep.EmitterLifeTime = 1.f;
|
||||
ep.ParticleLifeTime = 1.5f;
|
||||
ep.ParticlesPerTick = 1;
|
||||
ep.SpawnRate = 0.2;
|
||||
ep.EmittingAngle = glm::half_pi<float>();
|
||||
ep.Spread = 1.5f;
|
||||
ep.Position = transformComponentBrick->Position;
|
||||
ep.Radius = 0.05;
|
||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||
ep.Color = brickModel->Color + glm::vec4(1);
|
||||
ep.Speed = 50;
|
||||
EventBroker->Publish(ep);
|
||||
|
||||
//std::cout << "Combo: " << ball->Combo << std::endl;
|
||||
//std::cout << NumberOfBricks() << std::endl;
|
||||
//std::cout << "Brick Score: " << brick->Score << std::endl;
|
||||
@@ -426,12 +438,33 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
void dd::Systems::LevelSystem::GetNextLevel()
|
||||
{
|
||||
std::array<int, 42> level;
|
||||
// 0 is empty space.
|
||||
std::array<glm::vec4, 42> color;
|
||||
// Level array indicates type of brick.
|
||||
// 0 is empty space.
|
||||
// 1 is standard brick.
|
||||
// 2 is multiball brick.
|
||||
// 3 is lifebuoy brick.
|
||||
// 4 is sticky brick.
|
||||
// 5 is ink blaster brick.
|
||||
|
||||
// wolor array determines the color of standard bricks.
|
||||
// w is white.
|
||||
// r is red.
|
||||
// g is green.
|
||||
// b is blue.
|
||||
// y is yellow.
|
||||
// c is cyan.
|
||||
// m is magenta.
|
||||
// d is dark.
|
||||
// Feel free to make your own.
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 0);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 0);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 0);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 0);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 0);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 0);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 0);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 0);
|
||||
if (m_CurrentCluster == 0) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
@@ -441,6 +474,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 0,
|
||||
@@ -449,6 +489,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 1,
|
||||
@@ -457,6 +504,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -465,6 +519,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -473,6 +534,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 1) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
@@ -483,6 +551,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
1, 2, 1, 2, 1, 2, 1,
|
||||
1, 1, 0, 1, 0, 1, 1,
|
||||
4, 0, 0, 3, 0, 0, 5};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
r, g, b, y, c, m, d,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 1,
|
||||
@@ -491,6 +566,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{2, 0, 0, 0, 0, 0, 2,
|
||||
@@ -499,7 +581,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 1, 1, 1, 0, 1};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
level =
|
||||
{1, 2, 1, 1, 1, 2, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
@@ -507,6 +595,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 0, 0, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 1, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{1, 0, 1, 0, 1, 0, 1,
|
||||
@@ -515,12 +610,20 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 1, 0, 2, 0, 1, 0,
|
||||
1, 0, 1, 0, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 3) {
|
||||
|
||||
}
|
||||
|
||||
std::copy(std::begin(level), std::end(level), std::begin(m_Bricks));
|
||||
std::copy(std::begin(level), std::end(level), std::begin(m_Bricks));
|
||||
std::copy(std::begin(color), std::end(color), std::begin(m_Colors));
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||
|
||||
@@ -118,6 +118,17 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
||||
m_SquidLoaded = false;
|
||||
ball->InkBlaster = false;
|
||||
ball->Sticky = false;
|
||||
ball->Waiting = true;
|
||||
|
||||
{
|
||||
Events::InkBlasterOver e;
|
||||
e.Ball = m_AttachedSquid;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
Events::ActionButton e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user