pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldmap manager.hxx,1.18,1.19 surfac


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldmap manager.hxx,1.18,1.19 surface_drawable.cxx,1.2,1.3 surface_drawable.hxx,1.2,1.3 worldmap.hxx,1.21,1.22
Date: 7 Mar 2003 00:09:02 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv20430

Modified Files:
        manager.hxx surface_drawable.cxx surface_drawable.hxx 
        worldmap.hxx 
Log Message:
added option for automatic uncover if the pingu is covered by an object on the 
worldmap, still pretty primitive, but seems to get the job done


Index: manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/manager.hxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- manager.hxx 19 Feb 2003 23:03:51 -0000      1.18
+++ manager.hxx 7 Mar 2003 00:08:58 -0000       1.19
@@ -70,6 +70,7 @@
 
   bool is_init;
   bool exit_worldmap;
+  
   WorldMap* worldmap;
   WorldMap* new_worldmap;
 
@@ -91,6 +92,8 @@
   /** Exit the WorldMapManager and return to the previous screen */
   void on_escape_press ();
   /** @}*/
+
+  WorldMap* get_worldmap() { return worldmap; }
 
   /** Change the current map to the given map 
 

Index: surface_drawable.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/surface_drawable.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- surface_drawable.cxx        19 Feb 2003 09:50:36 -0000      1.2
+++ surface_drawable.cxx        7 Mar 2003 00:09:00 -0000       1.3
@@ -19,9 +19,13 @@
 
 #include <iostream>
 
+#include "../xml_file_reader.hxx"
 #include "../xml_helper.hxx"
 #include "../pingus_resource.hxx"
 #include "../gui/graphic_context.hxx"
+#include "manager.hxx"
+#include "worldmap.hxx"
+#include "pingus.hxx"
 #include "surface_drawable.hxx"
 
 namespace WorldMapNS {
@@ -29,26 +33,15 @@
 SurfaceDrawable::SurfaceDrawable(xmlDocPtr doc, xmlNodePtr cur)
   : Drawable(doc, cur)
 {
-  cur = cur->children;
-  while(cur)
-    {
-      if (XMLhelper::equal_str(cur->name, "surface"))
-        {
-          ResDescriptor desc = XMLhelper::parse_surface(doc, cur);
-          surface = PingusResource::load_surface(desc);
-        }
-      else if (XMLhelper::equal_str(cur->name, "position"))
-        {
-          pos = XMLhelper::parse_vector(doc, cur);
-        }
-      else
-        {
-          std::cout << "Uknown: " << cur->name << std::endl;
-        }
+  auto_uncover = false;
+  ResDescriptor desc;
 
-      cur = cur->next;
-      cur = XMLhelper::skip_blank(cur);
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_desc ("surface", desc);
+  reader.read_vector ("position", pos);
+  reader.read_bool ("auto-uncover", auto_uncover);
+
+  surface = PingusResource::load_surface(desc);
 }
 
 void
@@ -62,7 +55,20 @@
 {
   if (surface)
     {
-      gc.draw(surface, pos);
+      if (auto_uncover)
+        {
+          Vector pingus_pos = 
WorldMapManager::instance()->get_worldmap()->get_pingus()->get_pos();
+          if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x + 
surface.get_width()
+                && 
+                pingus_pos.y > pos.y && pingus_pos.y < pos.y + 
surface.get_height()))
+            {
+              gc.draw(surface, pos);
+            }
+        }
+      else
+        {
+          gc.draw(surface, pos);
+        }
     }
 }
 

Index: surface_drawable.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/surface_drawable.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- surface_drawable.hxx        13 Oct 2002 14:19:25 -0000      1.2
+++ surface_drawable.hxx        7 Mar 2003 00:09:00 -0000       1.3
@@ -32,6 +32,10 @@
 private:
   CL_Surface surface;
   Vector     pos;
+  /** If set to true the surface will disappear if the pingu gets
+      covered by it, so that the Pingu can travel into caves and other
+      things, while the roof will disapear */
+  bool       auto_uncover;
 public:
   SurfaceDrawable(xmlDocPtr doc, xmlNodePtr cur);
 

Index: worldmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.hxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- worldmap.hxx        19 Feb 2003 09:50:36 -0000      1.21
+++ worldmap.hxx        7 Mar 2003 00:09:00 -0000       1.22
@@ -80,6 +80,8 @@
   WorldMap(const std::string& filename);
   ~WorldMap();
 
+  Pingus* get_pingus() { return pingus; }
+
   void draw (GraphicContext& gc);
   void update ();
   





reply via email to

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