Skip to content

Commit 22349fe

Browse files
committed
Fixed problems I ran into while playtesting.
1 parent e4aae97 commit 22349fe

File tree

4 files changed

+66
-32
lines changed

4 files changed

+66
-32
lines changed

include/Game/BallSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class BallSystem : public System
105105
std::mt19937 m_RandomGenerator;
106106

107107
float m_XMovementMultiplier = 2.f;
108-
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
108+
float m_EdgeX = 3.2f;
109109
float m_EdgeY = 5.2f;
110110
int m_MultiBalls = 0;
111111
bool m_ReplaceBall = false;

src/game/Game/BallSystem.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,17 +471,17 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
471471
ball2->Waiting = false;
472472
auto padTransform = event.padTransform;
473473
float x1 = padTransform->Position.x/* - 2*/, x2 = padTransform->Position.x/* + 2*/;
474-
if (x1 < -m_EdgeX) {
475-
x1 = m_EdgeX - 0.2;
474+
if (x1 < -m_EdgeX + 0.4) {
475+
x1 = m_EdgeX - 0.7;
476476
}
477-
if (x2 > m_EdgeX) {
478-
x2 = -m_EdgeX + 0.2;
477+
if (x2 > m_EdgeX - 0.4) {
478+
x2 = -m_EdgeX + 0.7;
479479
}
480480
transform1->Position = glm::vec3(x1, -5.5, -10);
481481
transform2->Position = glm::vec3(x2, -5.5, -10);
482482

483-
transform1->Velocity = glm::normalize(glm::vec3(5, 5 ,0.f)) * ball1->Speed;
484-
transform2->Velocity = glm::normalize(glm::vec3(-5, 5 ,0.f)) * ball2->Speed;
483+
transform1->Velocity = glm::normalize(glm::vec3(2.5, 5 ,0.f)) * ball1->Speed;
484+
transform2->Velocity = glm::normalize(glm::vec3(-2.5, 5 ,0.f)) * ball2->Speed;
485485

486486
SetMultiBalls(MultiBalls() + 2);
487487
//std::cout << MultiBalls() << std::endl;

src/game/Game/LevelSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
12731273
level =
12741274
{0, 0, 0, 0, 0, 0, 0,
12751275
0, 0, 0, 0, 0, 0, 0,
1276-
0, 0, 0, 0, 0, 0, 0,
1276+
2, 2, 2, 2, 2, 2, 2,
12771277
0, 0, 0, 0, 0, 0, 0,
12781278
0, 0, 0, 0, 0, 0, 0,
12791279
0, 0, 0, 0, 0, 0, 1};

src/game/Game/LifebuoySystem.cpp

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void dd::Systems::LifebuoySystem::Initialize()
4444

4545
void dd::Systems::LifebuoySystem::Update(double dt)
4646
{
47-
for (auto it = m_Lifebuoys.begin(); it != m_Lifebuoys.end();) {
47+
/*for (auto it = m_Lifebuoys.begin(); it != m_Lifebuoys.end();) { //Niklas note: Jag fortstatte få fel efter ni gick hem, och jag förstod inte det här så jag gjorde om som jag visste hur i UpdateEntity.
4848
4949
auto transformComponent = m_World->GetComponent<Components::Transform>(it->Entity);
5050
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(it->Entity);
@@ -80,7 +80,7 @@ void dd::Systems::LifebuoySystem::Update(double dt)
8080
8181
++it;
8282
}
83-
}
83+
}*/
8484

8585
if (IsPaused()) {
8686
return;
@@ -103,6 +103,38 @@ void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, Entit
103103
}
104104
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
105105
if (templateCheck != nullptr){ return; }
106+
107+
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(entity);
108+
109+
if (lifebuoyComponent != nullptr) {
110+
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
111+
112+
if (transformComponent->Position.y < m_DownEdge) {
113+
m_World->RemoveEntity(entity);
114+
//m_Lifebuoys.erase(it++);
115+
}
116+
else {
117+
118+
if (transformComponent->Position.x > m_RightEdge) {
119+
transformComponent->Position = glm::vec3(m_LeftEdge + 0.1f, transformComponent->Position.y, transformComponent->Position.z);
120+
}
121+
else if (transformComponent->Position.x < m_LeftEdge) {
122+
transformComponent->Position = glm::vec3(m_RightEdge - 0.1f, transformComponent->Position.y, transformComponent->Position.z);
123+
}
124+
125+
if (lifebuoyComponent->Hits <= 0) {
126+
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
127+
physicsComponent->Mask = CollisionLayer::Type::LifeBuoy;
128+
physicsComponent->GravityScale = 10.f;
129+
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
130+
modelComponent->Color = glm::vec4(0.5f, 0.5f, 0.5f, 0.f);
131+
}
132+
133+
if (transformComponent->Position.y < m_DownLimit && lifebuoyComponent->Hits > 0) {
134+
transformComponent->Position.y = m_DownLimit;
135+
}
136+
}
137+
}
106138
}
107139

108140
bool dd::Systems::LifebuoySystem::OnPause(const dd::Events::Pause &event)
@@ -160,28 +192,30 @@ bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &e
160192
{
161193
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Lifebuoy);
162194
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(event.Lifebuoy);
163-
lifebuoyComponent->Hits -= 1;
164-
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
165-
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
166-
167-
Events::CreateParticleSequence e;
168-
e.EmitterLifeTime = 4;
169-
e.EmittingAngle = glm::half_pi<float>();
170-
e.Spread = 0.5f;
171-
e.NumberOfTicks = 1;
172-
e.ParticleLifeTime = 2.f;
173-
e.ParticlesPerTick = 1;
174-
e.Position = transformComponent->Position;
175-
e.ScaleValues.clear();
176-
e.ScaleValues.push_back(glm::vec3(0.5f));
177-
e.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
178-
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
179-
e.Color = glm::vec4(1, 0, 0, 1);
180-
e.AlphaValues.clear();
181-
e.AlphaValues.push_back(1.f);
182-
e.AlphaValues.push_back(0.f);
183-
e.Speed = 10.f;
184-
EventBroker->Publish(e);
195+
if (lifebuoyComponent != nullptr) {
196+
lifebuoyComponent->Hits -= 1;
197+
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
198+
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
199+
200+
Events::CreateParticleSequence e;
201+
e.EmitterLifeTime = 4;
202+
e.EmittingAngle = glm::half_pi<float>();
203+
e.Spread = 0.5f;
204+
e.NumberOfTicks = 1;
205+
e.ParticleLifeTime = 2.f;
206+
e.ParticlesPerTick = 1;
207+
e.Position = transformComponent->Position;
208+
e.ScaleValues.clear();
209+
e.ScaleValues.push_back(glm::vec3(0.5f));
210+
e.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
211+
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
212+
e.Color = glm::vec4(1, 0, 0, 1);
213+
e.AlphaValues.clear();
214+
e.AlphaValues.push_back(1.f);
215+
e.AlphaValues.push_back(0.f);
216+
e.Speed = 10.f;
217+
EventBroker->Publish(e);
218+
}
185219

186220
return true;
187221
}

0 commit comments

Comments
 (0)