pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3367 - in trunk/pingus/src: . components worldobjs


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3367 - in trunk/pingus/src: . components worldobjs
Date: Mon, 29 Oct 2007 01:59:01 +0100

Author: grumbel
Date: 2007-10-29 01:59:00 +0100 (Mon, 29 Oct 2007)
New Revision: 3367

Modified:
   trunk/pingus/src/components/playfield.cpp
   trunk/pingus/src/level_menu.cpp
   trunk/pingus/src/world.cpp
   trunk/pingus/src/world.hpp
   trunk/pingus/src/worldobjs/entrance.hpp
Log:
- fine tuned the start-pos workaround a bit more, now almost good enough to not 
need startpos any more, except for very special cases

Modified: trunk/pingus/src/components/playfield.cpp
===================================================================
--- trunk/pingus/src/components/playfield.cpp   2007-10-29 00:38:45 UTC (rev 
3366)
+++ trunk/pingus/src/components/playfield.cpp   2007-10-29 00:59:00 UTC (rev 
3367)
@@ -48,7 +48,7 @@
   state.set_limit(Rect(Vector2i(0, 0), Size(world->get_width(), 
world->get_height())));
 
   // FIXME: Temporary workaround till start-pos is integrated a bit more 
properly
-  state.set_pos(Vector2f(world->get_width()/2, world->get_height()/2));
+  state.set_pos(world->get_start_pos(0));
 }
 
 Playfield::~Playfield()

Modified: trunk/pingus/src/level_menu.cpp
===================================================================
--- trunk/pingus/src/level_menu.cpp     2007-10-29 00:38:45 UTC (rev 3366)
+++ trunk/pingus/src/level_menu.cpp     2007-10-29 00:59:00 UTC (rev 3367)
@@ -31,6 +31,7 @@
 #include "gui/gui_manager.hpp"
 #include "game_session.hpp"
 #include "start_screen.hpp"
+#include "globals.hpp"
 #include "gui/surface_button.hpp"
 #include "sound/sound.hpp"
 
@@ -202,8 +203,10 @@
             else if (i == current_level)
               gc.draw(marker, Vector2i(0, y));
                         
-            std::string level = levelset->get_level(i)->plf.get_levelname();
-            gc.print_left(Fonts::chalk_small, 30, y+4, level);
+            if (maintainer_mode)
+              gc.print_left(Fonts::chalk_small, 30, y+4, 
levelset->get_level(i)->plf.get_resname());
+            else
+              gc.print_left(Fonts::chalk_small, 30, y+4, 
levelset->get_level(i)->plf.get_levelname());
 
             if (levelset->get_level(i)->finished)
               gc.print_right(Fonts::chalk_small, rect.get_width() -30, y+4, 
"solved");

Modified: trunk/pingus/src/world.cpp
===================================================================
--- trunk/pingus/src/world.cpp  2007-10-29 00:38:45 UTC (rev 3366)
+++ trunk/pingus/src/world.cpp  2007-10-29 00:59:00 UTC (rev 3367)
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <typeinfo>
 #include "pingu_holder.hpp"
+#include "worldobjs/entrance.hpp"
 #include "sound/sound.hpp"
 #include "ground_map.hpp"
 #include "world.hpp"
@@ -38,7 +39,6 @@
 #include "game_time.hpp"
 #include "debug.hpp"
 
-
 using Actions::Bomber;
 
 static
@@ -312,4 +312,31 @@
   return 0;
 }
 
+Vector2i
+World::get_start_pos(int player_id)
+{
+  // FIXME: Workaround for lack of start-pos
+  Vector2i pos;
+  int num_entrances = 0;
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
+    {  
+      WorldObjs::Entrance* entrance = dynamic_cast<WorldObjs::Entrance*>(*obj);
+      if (entrance && entrance->get_owner_id() == player_id)
+        {
+          pos += Vector2i(static_cast<int>(entrance->get_pos().x),
+                          static_cast<int>(entrance->get_pos().y));
+          num_entrances += 1;
+        }
+    }
+
+  if (num_entrances > 0)
+    {
+      pos.x /= num_entrances;
+      pos.y /= num_entrances;
+      pos.y += 100;
+    }
+
+  return pos;
+}
+
 /* EOF */

Modified: trunk/pingus/src/world.hpp
===================================================================
--- trunk/pingus/src/world.hpp  2007-10-29 00:38:45 UTC (rev 3366)
+++ trunk/pingus/src/world.hpp  2007-10-29 00:59:00 UTC (rev 3367)
@@ -23,6 +23,7 @@
 #include "pingus.hpp"
 #include <vector>
 #include <string>
+#include "math/vector2i.hpp"
 #include "math/color.hpp"
 #include "groundtype.hpp"
 #include "collision_mask.hpp"
@@ -173,6 +174,9 @@
   /** Get the acceleration due to gravity in the world */
   float get_gravity();
 
+  /** Returns the start pos for the given player */
+  Vector2i get_start_pos(int player_id);
+
 private:
   World (const World&);
   World& operator= (const World&);

Modified: trunk/pingus/src/worldobjs/entrance.hpp
===================================================================
--- trunk/pingus/src/worldobjs/entrance.hpp     2007-10-29 00:38:45 UTC (rev 
3366)
+++ trunk/pingus/src/worldobjs/entrance.hpp     2007-10-29 00:59:00 UTC (rev 
3367)
@@ -67,6 +67,8 @@
 
   void  draw_smallmap(SmallMap* smallmap);
 
+  Vector3f get_pos() const { return pos; }
+  int get_owner_id() { return owner_id; }
 private:
   Entrance (const Entrance&);
   Entrance& operator= (const Entrance&);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]