Merge branch 'LevelSystemAndSuch', and adjusted ball size.

This commit is contained in:
PlatinumSkink
2015-10-06 20:35:44 +02:00
7 changed files with 42 additions and 40 deletions
-3
View File
@@ -77,8 +77,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; }
@@ -90,7 +88,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;
+14 -23
View File
@@ -25,12 +25,12 @@ void dd::Systems::BallSystem::Initialize()
auto ent = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(-0.f, 50.26f, -10.f);
transform->Scale = glm::vec3(0.2f, 0.2f, 0.2f);
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
auto model = m_World->AddComponent<Components::Model>(ent);
model->ModelFile = "Models/Test/Ball/Sid.obj";
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
circleShape->Radius = 0.2f;
circleShape->Radius = 0.4f;
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
ball->Speed = 5.f;
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
@@ -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++) {
@@ -237,15 +235,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);
@@ -324,11 +313,8 @@ void dd::Systems::BallSystem::ResolveContacts()
EntityID dd::Systems::BallSystem::CreateBall()
{
auto ent = m_World->CloneEntity(Ball());
m_World->RemoveComponent<Components::Template>(ent);
//m_World->CommitEntity(ent);
return ent;
}
@@ -343,7 +329,7 @@ void dd::Systems::BallSystem::CreateLife(int number)
lifeNr->Number = number;
auto model = m_World->AddComponent<Components::Model>(life);
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
model->ModelFile = "Models/Test/Ball/Sid.obj";
m_World->CommitEntity(life);
@@ -358,7 +344,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;
}
@@ -378,11 +369,11 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
auto ball2 = m_World->GetComponent<Components::Ball>(ent2);
auto padTransform = event.padTransform;
float x1 = padTransform->Position.x - 2, x2 = padTransform->Position.x + 2;
if (x1 < -3.1) {
x1 = 3;
if (x1 < -m_EdgeX) {
x1 = m_EdgeX - 0.2;
}
if (x2 > 3.1) {
x2 = -3;
if (x2 > m_EdgeX) {
x2 = -m_EdgeX + 0.2;
}
transform1->Position = glm::vec3(x1, -5.5, -10);
transform2->Position = glm::vec3(x2, -5.5, -10);
@@ -391,7 +382,7 @@ 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;
}
+1 -1
View File
@@ -16,7 +16,7 @@ void dd::Systems::HitLagSystem::Update(double dt)
if (IsPaused()) {
if (HitLag()) {
SetHitLagTimer(HitLagTimer() += dt);
std::cout << HitLagTimer() << std::endl;
//std::cout << HitLagTimer() << std::endl;
if (HitLagDuration() < HitLagTimer()) {
SetHitLagTimer(0);
SetHitLag(false);
+21 -13
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,10 +82,10 @@ 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);
Events::MultiBallLost e;
EventBroker->Publish(e);
m_World->RemoveEntity(entity);
} else {
auto powerUp = m_World->GetComponent<Components::PowerUp>(entity);
@@ -92,7 +95,6 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
} else {
if (brick != nullptr) {
m_LooseBricks--;
std::cout << m_LooseBricks << std::endl;
m_World->RemoveEntity(entity);
}
}
@@ -147,8 +149,9 @@ void dd::Systems::LevelSystem::CreateLevel()
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), num, m_Bricks[getter]);
getter++;
}
if (num == 1)
if (num == 1) {
num = Lines();
}
}
m_LooseBricks = NumberOfBricks();
SetRestarting(false);
@@ -156,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;
}
@@ -164,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";
@@ -175,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;
}
@@ -217,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;
@@ -285,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;
}
@@ -341,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 =
+1
View File
@@ -254,6 +254,7 @@ void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity)
return;
}
//It told me I was removing a lot of objects, and I didn't need that information, so I commented it out.
//LOG_INFO("Removing entity %i", entity);
it->second->GetWorld()->DestroyBody(it->second);
m_BodiesToEntities.erase(it->second);