Fixed all bugs I know of. MultiBall appear upon ice falling in water.

This commit is contained in:
PlatinumSkink
2015-10-06 19:41:24 +02:00
parent a3b21581e2
commit 902098a72d
5 changed files with 31 additions and 31 deletions
-3
View File
@@ -78,8 +78,6 @@ public:
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
bool ReplaceBall() const { return m_ReplaceBall; }
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
bool MultiBall() const { return m_MultiBall; }
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
@@ -91,7 +89,6 @@ private:
int m_Lives = 3;
int m_PastLives = 3;
bool m_ReplaceBall = false;
bool m_MultiBall = false;
bool m_Pause = false;
EntityID m_LastCollision = 999999;
+1
View File
@@ -16,6 +16,7 @@ namespace Components
struct Brick : Component
{
int Score = 50;
int Type = 0;
bool Removed = false;
};
+4
View File
@@ -120,6 +120,10 @@ private:
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
float m_NotResettingTheStage = 5.f;
const int EmptyBrickSpace = 0;
const int StandardBrick = 1;
const int MultiBallBrick = 2;
EntityID m_BrickTemplate;
std::array<int, 42> m_Bricks;
+7 -14
View File
@@ -51,8 +51,6 @@ 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);
m_World->CommitEntity(ent2);
}
for (int i = 0; i < Lives(); i++) {
@@ -236,15 +234,6 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
int hey = 5;
}
/*if (otherEntitiy == m_LastCollision) {
if (brick != nullptr) {
return false;
}
} else {
m_LastCollision = otherEntitiy;
}*/
//if this is a brick thats dead do not collide :)
auto ballTransform = m_World->GetComponent<Components::Transform>(ballEntity);
@@ -283,7 +272,6 @@ EntityID dd::Systems::BallSystem::CreateBall()
{
auto ent = m_World->CloneEntity(Ball());
m_World->RemoveComponent<Components::Template>(ent);
//m_World->CommitEntity(ent);
return ent;
}
@@ -314,7 +302,12 @@ bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
bool dd::Systems::BallSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event)
{
SetMultiBalls(MultiBalls()-1);
SetMultiBalls(MultiBalls() - 1);
std::cout << MultiBalls() << std::endl;
if (MultiBalls() < 0) {
auto ent = CreateBall();
SetMultiBalls(0);
}
return true;
}
@@ -347,6 +340,6 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
transform2->Velocity = glm::normalize(glm::vec3(-5, 5 ,0.f)) * ball2->Speed;
SetMultiBalls(MultiBalls() + 2);
std::cout << MultiBalls() << std::endl;
return true;
}
+19 -14
View File
@@ -47,7 +47,6 @@ void dd::Systems::LevelSystem::Initialize()
void dd::Systems::LevelSystem::Update(double dt)
{
if (!m_Initialized) {
//CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge());
GetNextLevel();
CreateLevel();
m_Initialized = true;
@@ -67,8 +66,12 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
auto transform = m_World->GetComponent<Components::Transform>(entity);
//Removes bricks that falls out of the stage.
if (transform->Position.y < -10) {
if (brick->Type == MultiBallBrick) {
Events::MultiBall e;
e.padTransform = transform;
EventBroker->Publish(e);
}
m_LooseBricks--;
//std::cout << m_LooseBricks << std::endl;
m_World->RemoveEntity(entity);
}
}
@@ -79,22 +82,19 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
if (MultiBalls() <= 0 && PowerUps() <= 0) {
Events::StageCleared ec;
EventBroker->Publish(ec);
//CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge());
} else {
if (ball != nullptr && MultiBalls() > 0) {
SetMultiBalls(MultiBalls()-1);
//std::cout << "Multi Balls: " << MultiBalls() << std::endl;
Events::MultiBallLost e;
EventBroker->Publish(e);
m_World->RemoveEntity(entity);
} else {
auto powerUp = m_World->GetComponent<Components::PowerUp>(entity);
if (powerUp != nullptr) {
SetPowerUps(PowerUps() - 1);
//std::cout << "Power Ups: " << PowerUps() << std::endl;
m_World->RemoveEntity(entity);
} else {
if (brick != nullptr) {
m_LooseBricks--;
//std::cout << "Loose Bricks: " << m_LooseBricks << std::endl;
m_World->RemoveEntity(entity);
}
}
@@ -159,7 +159,7 @@ void dd::Systems::LevelSystem::CreateLevel()
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int num, int typeInt)
{
if (typeInt == 0) {
if (typeInt == EmptyBrickSpace) {
SetNumberOfBricks(NumberOfBricks() - 1);
return;
}
@@ -167,9 +167,10 @@ 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 cPhys = m_World->GetComponent<Components::Physics>(brick);
if (typeInt == 2) {
if (typeInt == StandardBrick) {
} else if (typeInt == MultiBallBrick) {
cBrick->Type = MultiBallBrick;
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
auto model = m_World->GetComponent<Components::Model>(brick);
model->ModelFile = "Models/Brick/IceBrick.obj";
@@ -178,8 +179,6 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
float y = row * spacesBetweenBricks.y;
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f);
cBrick->Score = 10 * num;
m_World->CommitEntity(brick);
return;
}
@@ -220,13 +219,13 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
return false;
}
auto power = m_World->GetComponent<Components::PowerUpBrick>(entityBrick);
/*auto power = m_World->GetComponent<Components::PowerUpBrick>(entityBrick);
if (power != nullptr && NumberOfBricks() > 1) {
Events::CreatePowerUp e;
auto transform = m_World->GetComponent<Components::Transform>(entityBrick);
e.Position = transform->Position;
EventBroker->Publish(e);
}
}*/
if (!Restarting() && !brick->Removed) {
brick->Removed = true;
@@ -288,6 +287,9 @@ bool dd::Systems::LevelSystem::OnMultiBall(const dd::Events::MultiBall &event)
bool dd::Systems::LevelSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event)
{
SetMultiBalls(MultiBalls()-1);
if (MultiBalls() < 0) {
SetMultiBalls(0);
}
return true;
}
@@ -344,6 +346,9 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
void dd::Systems::LevelSystem::GetNextLevel()
{
std::array<int, 42> level;
// 0 is empty space.
// 1 is standard brick.
// 2 is multiball brick.
if (m_CurrentCluster == 1) {
if (m_CurrentLevel == 1) {
level =