pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src col_map.cxx,1.3,1.4 col_map.hxx,1.2,1


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src col_map.cxx,1.3,1.4 col_map.hxx,1.2,1.3 global_event.cxx,1.3,1.4 pingu.cxx,1.10,1.11
Date: 25 Jun 2002 17:05:27 -0000

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

Modified Files:
        col_map.cxx col_map.hxx global_event.cxx pingu.cxx 
Log Message:
- preparation to join PixelStatus and GroundType
- changed the colmap in a collection of enum's instead of a bitfield
- changed some actions for handling the new pixelstatus treatment (can somebody 
test this?)
- changed the colmap blitter so that overwriting ground with a bridge is not 
possible, this fixes a few stuckyness bugs
[This patch changes a few things where I am not 100% sure what they will cause, 
so testers are welcome to test a lot]

Index: col_map.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/col_map.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- col_map.cxx 19 Jun 2002 15:19:26 -0000      1.3
+++ col_map.cxx 25 Jun 2002 17:05:25 -0000      1.4
@@ -28,8 +28,8 @@
 #include <config.h>
 #include "my_gettext.hxx"
 
-
-ColMap::ColMap() : init(false)
+ColMap::ColMap() 
+  : init(false)
 {
 }
 
@@ -193,7 +193,7 @@
 ColMap::put(int x, int y, PixelStatus p)
 {
   if (   x > 0 && x < width
-      && y > 0 && y < height) 
+        && y > 0 && y < height) 
     {
       colmap[x+y*width] = p;
     }
@@ -221,6 +221,20 @@
     }
 }
 
+bool
+ColMap::blit_allowed (int x, int y,  GroundpieceData::GPType gtype)
+{
+  if (gtype == GroundpieceData::GP_BRIDGE)
+    {
+      int pixel = getpixel (x, y);
+      return pixel == NOTHING;
+    }
+  else
+    {
+      return true;
+    }
+}
+
 void
 ColMap::put(const CL_Surface& sur, int sur_x, int sur_y, 
GroundpieceData::GPType gptype)
 {
@@ -238,10 +252,10 @@
   switch (gptype) 
     {
     case GroundpieceData::GP_GROUND:  pixel = WALL; break;
-    case GroundpieceData::GP_SOLID:   pixel = (PixelStatus)(SOLID | WALL); 
break;
-    case GroundpieceData::GP_BRIDGE:  pixel = (PixelStatus)(BRIDGE | WALL); 
break;
-    case GroundpieceData::GP_WATER:   pixel = (PixelStatus)(SOLID | WATER); 
break;
-    case GroundpieceData::GP_LAVA:    pixel = (PixelStatus)(SOLID | LAVA); 
break;
+    case GroundpieceData::GP_SOLID:   pixel = (PixelStatus)(SOLID); break;
+    case GroundpieceData::GP_BRIDGE:  pixel = (PixelStatus)(BRIDGE); break;
+    case GroundpieceData::GP_WATER:   pixel = (PixelStatus)(WATER); break;
+    case GroundpieceData::GP_LAVA:    pixel = (PixelStatus)(LAVA); break;
     case GroundpieceData::GP_NOTHING: pixel = (PixelStatus)0; break;
     default:
       std::cout << "Colmap::put() Indefinite type" << std::endl;
@@ -249,13 +263,15 @@
       break;
     }
   
-  if ((sur_x > width) || (sur_y > height)) {
-    if (verbose > 3) {
-      std::cout << "Warning: ColMap: Spot out of screen" << std::endl;
-      std::cout << "sur_x: " << sur_x << " sur_y: " << sur_y << std::endl;
+  if ((sur_x > width) || (sur_y > height)) 
+    {
+      if (verbose > 3) 
+       {
+         std::cout << "Warning: ColMap: Spot out of screen" << std::endl;
+         std::cout << "sur_x: " << sur_x << " sur_y: " << sur_y << std::endl;
+       }
+      return;
     }
-    return;
-  }
 
   provider->lock();
   
@@ -263,13 +279,14 @@
     {
       float r, g, b, a;
       // Rewritting blitter for 32bit depth (using get_pixel())
-      for (unsigned int y=0; y < provider->get_height(); y++)
-       for (unsigned int x=0; x < provider->get_width(); x++) 
+      for (unsigned int y=0; y < provider->get_height(); ++y)
+       for (unsigned int x=0; x < provider->get_width(); ++x) 
          {
            provider->get_pixel(x, y, &r, &g, &b, &a);
-           if (a > 0.1)
+           if (a > 0.1) // Alpha threshold
              {
-               put(x + sur_x, y + sur_y, (PixelStatus) pixel);
+               if (blit_allowed (x + sur_x, y + sur_y, gptype))
+                 put(x + sur_x, y + sur_y, (PixelStatus) pixel);
              }
          }
     }
@@ -293,7 +310,10 @@
            for (int i = x_offset; i < swidth && (i+sur_x) < width; ++i) 
              {
                if (buffer[i + (swidth*line)] != colorkey)
-                 colmap[i + (width*(line+sur_y) + sur_x)] = pixel;             
    
+                 {
+                   if (blit_allowed (i + sur_x, line + sur_y, gptype))
+                     colmap[i + (width*(line+sur_y) + sur_x)] = pixel;         
    
+                 }
              }
        }
       else
@@ -301,7 +321,8 @@
          for(int line = y_offset; line < sheight && (line + sur_y) < height; 
++line) 
            for (int i = x_offset; i < swidth && (i+sur_x) < width; ++i) 
              {
-               colmap[i + (width*(line+sur_y) + sur_x)] = pixel;
+               if (blit_allowed (i + sur_x, line + sur_y, gptype))
+                 colmap[i + (width*(line+sur_y) + sur_x)] = pixel;
              }
        }
     }
@@ -333,12 +354,21 @@
          buffer[i * 4 + 2] = 0;
          buffer[i * 4 + 3] = 0;
          break;
+
        case ColMap::SOLID:
          buffer[i * 4 + 0] = 255;
          buffer[i * 4 + 1] = 100;
          buffer[i * 4 + 2] = 100;
          buffer[i * 4 + 3] = 100;
          break;
+
+       case ColMap::BRIDGE:
+         buffer[i * 4 + 0] = 255;
+         buffer[i * 4 + 1] = 0;
+         buffer[i * 4 + 2] = 0;
+         buffer[i * 4 + 3] = 200;
+         break;
+
        default:
          buffer[i * 4 + 0] = 255;
          buffer[i * 4 + 1] = 200;

Index: col_map.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/col_map.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- col_map.hxx 24 Jun 2002 22:52:54 -0000      1.2
+++ col_map.hxx 25 Jun 2002 17:05:25 -0000      1.3
@@ -47,7 +47,12 @@
   bool    init;
   
 public:
-  /** Each pixel contains of bit vector...
+  /** Each pixel contains of bit vector... 
+      (FIXME: difference between PixelStatus and GroundpieceData::GPType?!)
+
+      Answer: a GroundpieceData::GPType defines how a pingu behaves
+      when hitting the ground type, aposed to that the PixelStatus
+      mainly handles how the blitting is handled.      
    */
   enum PixelStatus { 
         NOTHING     = 0,
@@ -82,28 +87,21 @@
   ///
   int  load(unsigned char*, int w, int h);
 
-  ///
   int  load(ResDescriptor desc);
 
-  ///
   int  getpixel(int x, int y);
+  
+  /** Return true if the given GroundType i*/
+  bool blit_allowed (int x, int y,  GroundpieceData::GPType);
 
-  ///
   void put(int x, int y, PixelStatus p = WALL);
-
-  ///
   void put(const CL_Surface&, int x, int y, GroundpieceData::GPType);
-
-  ///
   void put(CL_SurfaceProvider*, int x, int y, GroundpieceData::GPType);
 
   /// void remove(int x, int y);
   void remove(const CL_Surface&, int x, int y);
-
-  ///
   void remove(CL_SurfaceProvider*, int x, int y);
 
-  ///
   void draw(int, int, float);
 };
 

Index: global_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/global_event.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- global_event.cxx    20 Jun 2002 12:22:51 -0000      1.3
+++ global_event.cxx    25 Jun 2002 17:05:25 -0000      1.4
@@ -25,6 +25,7 @@
 #include "console.hxx"
 #include "fps_counter.hxx"
 #include "global_event.hxx"
+#include "globals.hxx"
 
 GlobalEvent global_event;
 
@@ -79,6 +80,10 @@
            //console << "!\"#$%&'()*+,-./0123456789:;<=>?@";
            console.newline();
          }
+         break;
+
+       case CL_KEY_C:
+         draw_collision_map = !draw_collision_map;
          break;
 
        case CL_KEY_END:

Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pingu.cxx   24 Jun 2002 14:25:03 -0000      1.10
+++ pingu.cxx   25 Jun 2002 17:05:25 -0000      1.11
@@ -41,8 +41,8 @@
     countdown_action (0),
     id (++id_counter),
     font (PingusResource::load_font("Fonts/numbers", "fonts")),
-    status (PS_ALIVE),
     environment (ENV_LAND),
+    status (PS_ALIVE),
     owner_id (owner),
     pos (arg_pos)
 {




reply via email to

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