diff --git a/flappybird/src/Level/Level.cpp b/flappybird/src/Level/Level.cpp index 5ce7c961..a1519507 100644 --- a/flappybird/src/Level/Level.cpp +++ b/flappybird/src/Level/Level.cpp @@ -44,6 +44,7 @@ namespace FlappyBird { float rand = Random::Float() * 7.0f - 4.0f; float diff = 7.0f; + glm::vec4 color = {Random::Float(), Random::Float(), Random::Float(), 1}; auto &ts_h = spike_haut.GetComponent(); @@ -51,15 +52,21 @@ namespace FlappyBird { _Scene->GetEntityByName("SpaceShip").GetComponent().Translation.x - 15.0f) { ts_h.Translation.x += 40.0f; ts_h.Translation.y = rand + diff; + auto &sp_h = spike_haut.GetComponent(); + sp_h.Color = color; } + auto &ts_b = spike_bas.GetComponent(); if (ts_b.Translation.x < _Scene->GetEntityByName("SpaceShip").GetComponent().Translation.x - 15.0f) { ts_b.Translation.x += 40.0f; ts_b.Translation.y = rand - diff - 3.0f; + auto &sp_b = spike_bas.GetComponent(); + sp_b.Color = color; } + } auto spike_haut2 = _Scene->GetEntityByName("spike_haut2"); @@ -67,8 +74,9 @@ namespace FlappyBird { if (spike_haut2 != nullptr && spike_bas2 != nullptr) { - float rand2 = Random::Float() * 7.0f - 4.0f; + float rand2 = Random::Float() * 8.0f - 4.0f; float diff2 = 7.0f; + glm::vec4 color = {Random::Float(), Random::Float(), Random::Float(), 1}; auto &ts_h2 = spike_haut2.GetComponent(); @@ -76,15 +84,21 @@ namespace FlappyBird { _Scene->GetEntityByName("SpaceShip").GetComponent().Translation.x - 15.0f) { ts_h2.Translation.x += 40.0f; ts_h2.Translation.y = rand2 + diff2; + auto &sp_h2 = spike_haut2.GetComponent(); + sp_h2.Color = color; } + auto &ts_b2 = spike_bas2.GetComponent(); if (ts_b2.Translation.x < _Scene->GetEntityByName("SpaceShip").GetComponent().Translation.x - 15.0f) { ts_b2.Translation.x += 40.0f; ts_b2.Translation.y = rand2 - diff2 - 3.0f; + auto &sp_b2 = spike_bas2.GetComponent(); + sp_b2.Color = color; } + } _Scene->OnUpdateRuntime(ts); @@ -112,6 +126,51 @@ namespace FlappyBird { PrefabsImporter::LoadPrefabs("Assets/Prefabs/FlappyBird.prefab", _Scene); PrefabsImporter::LoadPrefabs("Assets/Prefabs/obstacle.prefab", _Scene); + auto spike_haut = _Scene->GetEntityByName("spike_haut"); + auto spike_bas = _Scene->GetEntityByName("spike_bas"); + + if (spike_haut != nullptr && spike_bas != nullptr) { + + float rand = Random::Float() * 7.0f - 4.0f; + float diff = 7.0f; + glm::vec4 color = {Random::Float(), Random::Float(), Random::Float(), 1}; + + auto &ts_h = spike_haut.GetComponent(); + ts_h.Translation.y = rand + diff; + auto &sp_h = spike_haut.GetComponent(); + sp_h.Color = color; + + auto &ts_b = spike_bas.GetComponent(); + ts_b.Translation.y = rand - diff - 3.0f; + auto &sp_b = spike_bas.GetComponent(); + sp_b.Color = color; + + } + + auto spike_haut2 = _Scene->GetEntityByName("spike_haut2"); + auto spike_bas2 = _Scene->GetEntityByName("spike_bas2"); + + if (spike_haut2 != nullptr && spike_bas2 != nullptr) { + + float rand2 = Random::Float() * 8.0f - 4.0f; + float diff2 = 7.0f; + glm::vec4 color = {Random::Float(), Random::Float(), Random::Float(), 1}; + + auto &ts_h2 = spike_haut2.GetComponent(); + + ts_h2.Translation.y = rand2 + diff2; + auto &sp_h2 = spike_haut2.GetComponent(); + sp_h2.Color = color; + + + + auto &ts_b2 = spike_bas2.GetComponent(); + ts_b2.Translation.y = rand2 - diff2 - 3.0f; + auto &sp_b2 = spike_bas2.GetComponent(); + sp_b2.Color = color; + + } + _Scene->OnViewportResize(Application::Get().GetWindow().GetWidth(), Application::Get().GetWindow().GetHeight()); }