-made flapping less powerful by reducing speed and height
[supertux.git] / src / level.cpp
index 4aa7042..f7906ab 100644 (file)
@@ -39,6 +39,7 @@
 #include "resources.h"
 #include "gameobjs.h"
 #include "utils/lispwriter.h"
+#include "tilemap.h"
 
 using namespace std;
 
@@ -157,3 +158,63 @@ Level::get_sector(const std::string& name)
   return i->second;
 }
 
+Sector*
+Level::get_next_sector(const Sector* sector)
+{
+  for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
+    {
+    if(i->second == sector)
+      {
+      i++;
+      if(i == sectors.end())
+        return NULL;
+      return i->second;
+      }
+    }
+  std::cerr << "Warning: Sector not found on level\n";
+  return NULL;
+}
+
+Sector*
+Level::get_previous_sector(const Sector* sector)
+{
+  for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
+    {
+    if(i->second == sector)
+      {
+      if(i == sectors.begin())
+        return NULL;
+      i--;
+      return i->second;
+      }
+    }
+  std::cerr << "Warning: Sector not found on level\n";
+  return NULL;
+}
+
+int
+Level::get_total_sectors()
+{
+return sectors.size();
+}
+
+int
+Level::get_total_badguys()
+{
+  int total_badguys = 0;
+  for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
+    total_badguys += i->second->get_total_badguys();
+  return total_badguys;
+}
+
+int
+Level::get_total_coins()
+{
+  int total_coins = 0;
+  for(Sectors::iterator it = sectors.begin(); it != sectors.end(); ++it)
+    for(int x = 0; static_cast<unsigned int>(x) < it->second->solids->get_width(); x++)
+      for(int y = 0; static_cast<unsigned int>(y) < it->second->solids->get_height(); y++)
+        if(it->second->solids->get_tile(x,y)->attributes & Tile::COIN)
+          total_coins++;
+  return total_coins;
+}