added seacircles level
authorFrank DeMarco <if.self.end@gmail.com>
Sun, 6 Sep 2020 20:05:37 +0000 (16:05 -0400)
committerFrank DeMarco <if.self.end@gmail.com>
Sun, 6 Sep 2020 20:05:37 +0000 (16:05 -0400)
BuddiSystem.cpp
Sea.cpp
Sea.hpp
lib/sfw

index 9c3ae16..7f89dfe 100644 (file)
@@ -32,8 +32,8 @@ BuddiSystem::BuddiSystem()
     // Mix_PlayMusic(music, -1);
     buddi.set_draw_children_on_frame(false);
     levels = {
-        new Seafront(this), new Seafloor(this), new Seaside(this), new Seabed(this),
-        new Seawell(this), new Seabreeze(this), new Seacurtain(this), new Searupt(this),
+        new Seafront(this), new Seafloor(this), new Seaside(this), new Seaparade(this),
+        new Seawell(this), new Seacircles(this), new Seacurtain(this), new Searupt(this),
         new Seasqueeze(this), new Seaking(this), garden_level
     };
     crew.reserve(6);
diff --git a/Sea.cpp b/Sea.cpp
index 2eacb30..d17305f 100644 (file)
--- a/Sea.cpp
+++ b/Sea.cpp
@@ -869,7 +869,7 @@ void Seaside::update()
     }
 }
 
-Seabed::Seabed(Node* parent) : Sea(parent)
+Seaparade::Seaparade(Node* parent) : Sea(parent)
 {
     world_box = {{0, 0}, {1600, get_window_box().get_h()}};
     floors.reserve(4);
@@ -900,7 +900,7 @@ Seabed::Seabed(Node* parent) : Sea(parent)
     jellyfish_respawn_point = x;
 }
 
-void Seabed::load()
+void Seaparade::load()
 {
     Sea::load();
     floors[0].move({-50, 0});
@@ -919,7 +919,7 @@ void Seabed::load()
     }
 }
 
-void Seabed::restart()
+void Seaparade::restart()
 {
     clownfish.set_frameset("left");
     place_cans({{700, 262}, {870, 262}, {1400, 190}, {1320, 352}});
@@ -929,7 +929,7 @@ void Seabed::restart()
     scientist.update();
 }
 
-void Seabed::update()
+void Seaparade::update()
 {
     if (is_active())
     {
@@ -1037,7 +1037,66 @@ void Seawell::update()
     Sea::update();
 }
 
-Seabreeze::Seabreeze(Node* parent) : Sea(parent) {}
+Seacircles::Seacircles(Node* parent) : Sea(parent)
+{
+    world_box = {{0, 0}, {1225, 405}};
+    jellyfish.reserve(5);
+    for (int ii = 0; ii < 5; ii++)
+    {
+        jellyfish.emplace_back(this, glm::vec2(60, 60), -1);
+    }
+    floors.reserve(3);
+    floors.emplace_back(this, 480, 17, true);
+    floors.emplace_back(this, 570, 17, true);
+    floors.emplace_back(this, 370, 180);
+    corals.reserve(3);
+    corals.emplace_back(this, "diploria-labyrinthiformis", glm::vec2(-70, -70));
+    corals.emplace_back(this, "diploria-labyrinthiformis", glm::vec2(-70, -40));
+    corals.emplace_back(this, "acropora-latistella");
+    cans.reserve(4);
+    cans.emplace_back(this, true);
+    cans.emplace_back(this, false, true);
+    cans.emplace_back(this);
+    cans.emplace_back(this, true);
+    clownfish_start = {700, 325};
+    recycle_start = {290, 90};
+    anemone_start = {120, 240};
+}
+
+void Seacircles::load()
+{
+    Sea::load();
+    floors[1].move({world_box.get_w() - floors[1].get_w(), 0});
+    floors[2].move({440, 0});
+    corals[0].move({70, get_window_box().get_h() - floors[0].get_h() - corals[0].get_h()});
+    corals[1].move({460, floors[2].get_top() - corals[1].get_bottom()});
+    corals[2].move({850, floors[0].get_top() - corals[2].get_bottom()});
+}
+
+void Seacircles::restart()
+{
+    clownfish.set_frameset("right");
+    jellyfish_angle = 0.0f;
+    Sea::restart();
+    place_cans({{140, 250}, {570, 250}, {620, 22}, {1175, 368}});
+}
+
+void Seacircles::update()
+{
+    if (is_active())
+    {
+        float angle = jellyfish_angle, pi = glm::pi<float>();
+        glm::vec2 location;
+        for (std::size_t ii = 0; ii < jellyfish.size(); ii++, angle += 2 * pi / jellyfish.size())
+        {
+            location = sfw::get_point_on_circle({700, 320}, 290, angle);
+            location.x += world_box.get_left();
+            jellyfish[ii].set_center(location);
+        }
+        jellyfish_angle -= root->weight(.00363f);
+        Sea::update();
+    }
+}
 
 Seacurtain::Seacurtain(Node* parent) : Sea(parent) {}
 
diff --git a/Sea.hpp b/Sea.hpp
index e48046b..8bcf8bd 100644 (file)
--- a/Sea.hpp
+++ b/Sea.hpp
@@ -237,12 +237,12 @@ struct Seaside : Sea
 
 };
 
-struct Seabed : Sea
+struct Seaparade : Sea
 {
 
     float jellyfish_respawn_point, jellyfish_speed = 0.832f;
 
-    Seabed(Node*);
+    Seaparade(Node*);
     void load();
     void restart();
     void update();
@@ -264,10 +264,15 @@ struct Seawell : Sea
 
 };
 
-struct Seabreeze : Sea
+struct Seacircles : Sea
 {
 
-    Seabreeze(Node*);
+    float jellyfish_angle = 0.0f;
+
+    Seacircles(Node*);
+    void load();
+    void restart();
+    void update();
 
 };
 
diff --git a/lib/sfw b/lib/sfw
index df8bf26..c6341d2 160000 (submodule)
--- a/lib/sfw
+++ b/lib/sfw
@@ -1 +1 @@
-Subproject commit df8bf267f02f3f9fb3e4136d97d8dcf0a9a2f26b
+Subproject commit c6341d2bfc9d5a1c9007e6ae6f48a77390a7415b