StyleGuide Fix
This commit is contained in:
@@ -13,8 +13,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, LevelSystem::LifeLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScoreEvent, LevelSystem::ScoreEvent);
|
||||
|
||||
for (int i = 0; i < lives; i++)
|
||||
{
|
||||
for (int i = 0; i < Lives(); i++) {
|
||||
CreateLife(i);
|
||||
}
|
||||
|
||||
@@ -29,7 +28,7 @@ void dd::Systems::LevelSystem::CreateLife(int number)
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
|
||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||
lifeNr->number = number;
|
||||
lifeNr->Number = number;
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(life);
|
||||
sprite->SpriteFile = "Textures/Ball.png";
|
||||
@@ -40,7 +39,7 @@ void dd::Systems::LevelSystem::CreateLife(int number)
|
||||
void dd::Systems::LevelSystem::Update(double dt)
|
||||
{
|
||||
if (!m_Initialized) {
|
||||
CreateBasicLevel(tRows, tLines, tSpaceBetweenBricks, tSpaceToEdge);
|
||||
CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge());
|
||||
m_Initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -49,13 +48,10 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
{
|
||||
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
||||
|
||||
if (ball != NULL)
|
||||
{
|
||||
if (ball != NULL) {
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transformBall->Position.y < -10)
|
||||
{
|
||||
if (lives == pastLives)
|
||||
{
|
||||
if (transformBall->Position.y < -10) {
|
||||
if (Lives() == PastLives()) {
|
||||
Events::LifeLost e;
|
||||
e.Entity = entity;
|
||||
EventBroker->Publish(e);
|
||||
@@ -66,14 +62,12 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
}
|
||||
|
||||
if (lives != pastLives)
|
||||
{
|
||||
if (Lives() != PastLives()) {
|
||||
auto life = m_World->GetComponent<Components::Life>(entity);
|
||||
if (life != NULL)
|
||||
{
|
||||
if (life->number + 1 == pastLives) {
|
||||
if (life != NULL) {
|
||||
if (life->Number + 1 == PastLives()) {
|
||||
m_World->RemoveEntity(entity);
|
||||
pastLives = lives;
|
||||
SetPastLives(Lives());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,12 +76,10 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, int spaceToEdge)
|
||||
{
|
||||
int num = 0;
|
||||
numberOfBricks = rows * lines;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
SetNumberOfBricks(rows * lines);
|
||||
for (int i = 0; i < rows; i++) {
|
||||
num++;
|
||||
for (int j = 0; j < lines; j++)
|
||||
{
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num);
|
||||
}
|
||||
if (num == 7)
|
||||
@@ -127,11 +119,9 @@ void dd::Systems::LevelSystem::ProcessCollision()
|
||||
void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
||||
{
|
||||
/*auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||
if (brick != NULL)
|
||||
{
|
||||
if (brick != NULL) {
|
||||
numberOfBricks--;
|
||||
if (numberOfBricks < 1)
|
||||
{
|
||||
if (numberOfBricks < 1) {
|
||||
EndLevel();
|
||||
}
|
||||
}*/
|
||||
@@ -142,43 +132,41 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
EntityID entityBrick = event.Entity1;
|
||||
auto brick = m_World->GetComponent<Components::Brick>(entityBrick);
|
||||
if (brick == NULL)
|
||||
{
|
||||
if (brick == NULL) {
|
||||
return false;
|
||||
}
|
||||
EntityID entityBall = event.Entity2;
|
||||
|
||||
m_World->RemoveEntity(entityBrick);
|
||||
|
||||
numberOfBricks--;
|
||||
if (numberOfBricks == 0)
|
||||
{
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
if (NumberOfBricks() == 0) {
|
||||
Events::ScoreEvent es;
|
||||
es.score = 500;
|
||||
es.Score = 500;
|
||||
EventBroker->Publish(es);
|
||||
Events::ResetBall e;
|
||||
EventBroker->Publish(e);
|
||||
CreateBasicLevel(tRows, tLines, tSpaceBetweenBricks, tSpaceToEdge);
|
||||
CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge());
|
||||
}
|
||||
Events::ScoreEvent es;
|
||||
es.score = brick->Score;
|
||||
es.Score = brick->Score;
|
||||
EventBroker->Publish(es);
|
||||
|
||||
std::cout << "Score: " << score << std::endl;
|
||||
std::cout << "Score: " << Score() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::LifeLost(const dd::Events::LifeLost &event)
|
||||
{
|
||||
lives--;
|
||||
SetLives(Lives() - 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::ScoreEvent(const dd::Events::ScoreEvent &event)
|
||||
{
|
||||
score += event.score;
|
||||
SetScore(Score() += event.Score);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+45
-66
@@ -33,8 +33,8 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
{
|
||||
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
||||
if (ball != NULL) {
|
||||
if (replaceBall == true) {
|
||||
replaceBall = false;
|
||||
if (ReplaceBall() == true) {
|
||||
SetReplaceBall(false);
|
||||
|
||||
auto transformEntity = m_World->GetComponent<Components::Transform>(entity);
|
||||
transformEntity->Position = glm::vec3(20, 20, -10);
|
||||
@@ -65,71 +65,65 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
|
||||
void dd::Systems::PadSystem::Update(double dt)
|
||||
{
|
||||
if (ent == 0) {
|
||||
if (Entity() == 0) {
|
||||
for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) {
|
||||
if (m_World->GetProperty<std::string>(it->first, "Name") == "Pad") {
|
||||
ent = it->first;
|
||||
transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
pad = m_World->GetComponent<Components::Pad>(ent);
|
||||
SetEntity(it->first);
|
||||
SetTransform(m_World->GetComponent<Components::Transform>(Entity()));
|
||||
SetPad(m_World->GetComponent<Components::Pad>(Entity()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (transform->Velocity.x < -pad->maxSpeed)
|
||||
{
|
||||
transform->Velocity.x = -pad->maxSpeed;
|
||||
auto transform = Transform();
|
||||
auto pad = Pad();
|
||||
auto acceleration = Acceleration();
|
||||
|
||||
if (transform->Velocity.x < -pad->MaxSpeed) {
|
||||
transform->Velocity.x = -pad->MaxSpeed;
|
||||
}
|
||||
else if (transform->Velocity.x > pad->maxSpeed)
|
||||
{
|
||||
transform->Velocity.x = pad->maxSpeed;
|
||||
else if (transform->Velocity.x > pad->MaxSpeed) {
|
||||
transform->Velocity.x = pad->MaxSpeed;
|
||||
}
|
||||
transform->Position += transform->Velocity * (float)dt;
|
||||
transform->Velocity += acceleration * (float)dt;
|
||||
transform->Velocity -= transform->Velocity * pad->slowdownModifier * (float)dt;
|
||||
transform->Velocity -= transform->Velocity * pad->SlowdownModifier * (float)dt;
|
||||
|
||||
if (left)
|
||||
{
|
||||
acceleration.x = -pad->accelerationSpeed;
|
||||
if (Left()) {
|
||||
acceleration.x = -pad->AccelerationSpeed;
|
||||
}
|
||||
else if (right)
|
||||
{
|
||||
acceleration.x = pad->accelerationSpeed;
|
||||
else if (Right()) {
|
||||
acceleration.x = pad->AccelerationSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
acceleration.x = 0.f;
|
||||
}
|
||||
|
||||
SetTransform(transform);
|
||||
SetPad(pad);
|
||||
SetAcceleration(acceleration);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
{
|
||||
int val = event.KeyCode;
|
||||
if (val == GLFW_KEY_UP)
|
||||
{
|
||||
if (val == GLFW_KEY_UP) {
|
||||
//std::cout << "Up!" << std::endl;
|
||||
}
|
||||
else if (val == GLFW_KEY_DOWN)
|
||||
{
|
||||
} else if (val == GLFW_KEY_DOWN) {
|
||||
//std::cout << "Down!" << std::endl;
|
||||
}
|
||||
else if (val == GLFW_KEY_LEFT)
|
||||
{
|
||||
} else if (val == GLFW_KEY_LEFT) {
|
||||
//std::cout << "Left!" << std::endl;
|
||||
//acceleration.x = -0.01f;
|
||||
left = true;
|
||||
}
|
||||
else if (val == GLFW_KEY_RIGHT)
|
||||
{
|
||||
SetLeft(true);
|
||||
} else if (val == GLFW_KEY_RIGHT) {
|
||||
//std::cout << "Right!" << std::endl;
|
||||
//acceleration.x = 0.01f;
|
||||
right = true;
|
||||
}
|
||||
else if (val == GLFW_KEY_R)
|
||||
{
|
||||
replaceBall = true;
|
||||
SetRight(true);
|
||||
} else if (val == GLFW_KEY_R) {
|
||||
SetReplaceBall(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -137,21 +131,14 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
bool dd::Systems::PadSystem::OnKeyUp(const dd::Events::KeyUp &event)
|
||||
{
|
||||
int val = event.KeyCode;
|
||||
if (val == GLFW_KEY_UP)
|
||||
{
|
||||
if (val == GLFW_KEY_UP) {
|
||||
|
||||
}
|
||||
else if (val == GLFW_KEY_DOWN)
|
||||
{
|
||||
} else if (val == GLFW_KEY_DOWN) {
|
||||
|
||||
}
|
||||
else if (val == GLFW_KEY_LEFT)
|
||||
{
|
||||
left = false;
|
||||
}
|
||||
else if (val == GLFW_KEY_RIGHT)
|
||||
{
|
||||
right = false;
|
||||
} else if (val == GLFW_KEY_LEFT) {
|
||||
SetLeft(false);
|
||||
} else if (val == GLFW_KEY_RIGHT) {
|
||||
SetRight(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -160,14 +147,12 @@ bool dd::Systems::PadSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
EntityID entityBall = event.Entity2;
|
||||
auto ball = m_World->GetComponent<Components::Ball>(entityBall);
|
||||
if (ball == NULL)
|
||||
{
|
||||
if (ball == NULL) {
|
||||
return false;
|
||||
}
|
||||
EntityID entityPad = event.Entity1;
|
||||
auto pad = m_World->GetComponent<Components::Pad>(entityPad);
|
||||
if (pad == NULL)
|
||||
{
|
||||
if (pad == NULL) {
|
||||
return false;
|
||||
}
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entityBall);
|
||||
@@ -177,13 +162,10 @@ bool dd::Systems::PadSystem::OnContact(const dd::Events::Contact &event)
|
||||
|
||||
float whatX = transformBall->Position.x - transformPad->Position.x;
|
||||
float movementX;
|
||||
if (whatX > 0)
|
||||
{
|
||||
if (whatX > 0) {
|
||||
movementX = movementMultiplier * whatX;
|
||||
//std::cout << "Right!" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
movementX = movementMultiplier * whatX;
|
||||
//std::cout << "Left!" << std::endl;
|
||||
}
|
||||
@@ -219,7 +201,7 @@ bool dd::Systems::PadSystem::OnContact(const dd::Events::Contact &event)
|
||||
|
||||
bool dd::Systems::PadSystem::ResetBall(const dd::Events::ResetBall &event)
|
||||
{
|
||||
replaceBall = true;
|
||||
SetReplaceBall(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -229,12 +211,9 @@ bool dd::Systems::PadSystem::PadSteeringInputController::OnCommand(const Events:
|
||||
|
||||
std::cout << "Command!" << std::endl;
|
||||
|
||||
if (command == "right")
|
||||
{
|
||||
if (command == "right") {
|
||||
std::cout << "Right!" << std::endl;
|
||||
}
|
||||
else if (command == "left")
|
||||
{
|
||||
} else if (command == "left") {
|
||||
std::cout << "Left!" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user