pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] rev 2322 - in trunk: data/data src src/actions


From: Ingo Ruhnke
Subject: [Pingus-CVS] rev 2322 - in trunk: data/data src src/actions
Date: Sun, 09 May 2004 18:44:16 +0200

Author: grumbel
Date: 2004-05-09 18:44:16 +0200 (Sun, 09 May 2004)
New Revision: 2322

Modified:
   trunk/data/data/pingus.xml
   trunk/src/actions/basher.cxx
   trunk/src/actions/basher.hxx
   trunk/src/actions/bomber.cxx
   trunk/src/actions/bomber.hxx
   trunk/src/actions/bridger.cxx
   trunk/src/actions/bridger.hxx
   trunk/src/actions/digger.cxx
   trunk/src/actions/digger.hxx
   trunk/src/blitter.cxx
Log:
- some cleanup

Modified: trunk/data/data/pingus.xml
===================================================================
--- trunk/data/data/pingus.xml  2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/data/data/pingus.xml  2004-05-09 16:44:16 UTC (rev 2322)
@@ -346,6 +346,7 @@
       </image>
     </sprite>
   </section>
+
   <section name="Other">
     <sprite name="brick_right">
       <image file="../images/pingus/brick_right.png" />

Modified: trunk/src/actions/basher.cxx
===================================================================
--- trunk/src/actions/basher.cxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/basher.cxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -34,8 +34,8 @@
 Basher::Basher (Pingu* p)
   : PinguAction(p),
     sprite("Pingus/basher0", resources),
-    bash_radius(PingusResource::load_surface("Other/bash_radius", "pingus")),
-    bash_radius_gfx(PingusResource::load_surface("Other/bash_radius_gfx", 
"pingus")),
+    bash_radius(PingusResource::load_pixelbuffer("Other/bash_radius", 
"pingus")),
+    bash_radius_gfx(PingusResource::load_pixelbuffer("Other/bash_radius_gfx", 
"pingus")),
     basher_c(0),
     first_bash(true)
 {
@@ -112,14 +112,12 @@
 void
 Basher::bash()
 {
-#ifdef CLANLIB_0_6
   WorldObj::get_world()->get_colmap()->remove(bash_radius,
                                              static_cast<int>(pingu->get_x () 
- (bash_radius_width / 2)),
                                              static_cast<int>(pingu->get_y () 
- bash_radius_width + 1));
   WorldObj::get_world()->get_gfx_map()->remove(bash_radius_gfx,
                                               static_cast<int>(pingu->get_x () 
- (bash_radius_gfx_width / 2)),
                                               static_cast<int>(pingu->get_y () 
- bash_radius_gfx_width + 1));
-#endif
 }
 
 void

Modified: trunk/src/actions/basher.hxx
===================================================================
--- trunk/src/actions/basher.hxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/basher.hxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -30,8 +30,8 @@
 {
 private:
   CL_Sprite sprite;
-  CL_Surface bash_radius;
-  CL_Surface bash_radius_gfx;
+  CL_PixelBuffer bash_radius;
+  CL_PixelBuffer bash_radius_gfx;
   int basher_c;
   bool first_bash;
 

Modified: trunk/src/actions/bomber.cxx
===================================================================
--- trunk/src/actions/bomber.cxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/bomber.cxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -37,8 +37,8 @@
 namespace Actions {
 
 bool Bomber::static_surface_loaded = false;
-CL_Surface Bomber::bomber_radius;
-CL_Surface Bomber::bomber_radius_gfx;
+CL_PixelBuffer Bomber::bomber_radius;
+CL_PixelBuffer Bomber::bomber_radius_gfx;
 
 Bomber::Bomber (Pingu* p)
   : PinguAction(p),
@@ -48,14 +48,14 @@
     colmap_exploded(false),
     sprite("Pingus/bomber" + to_string(pingu->get_owner()), "pingus", 
            17.0f, Sprite::NONE, Sprite::ONCE),
-    explo_surf(PingusResource::load_surface("Other/explo" + 
to_string(pingu->get_owner()), "pingus"))
+    explo_surf(PingusResource::load_sprite("Other/explo" + 
to_string(pingu->get_owner()), "pingus"))
 {
   // Only load the surface again if no static_surface is available
   if (!static_surface_loaded)
     {
       static_surface_loaded = true;
-      bomber_radius     = PingusResource::load_surface ("Other/bomber_radius", 
"pingus");
-      bomber_radius_gfx = PingusResource::load_surface 
("Other/bomber_radius_gfx", "pingus");
+      bomber_radius     = 
PingusResource::load_pixelbuffer("Other/bomber_radius", "pingus");
+      bomber_radius_gfx = 
PingusResource::load_pixelbuffer("Other/bomber_radius_gfx", "pingus");
     }
   sprite.set_align_center_bottom();
 }
@@ -125,10 +125,10 @@
   if (sprite.get_frame () >= 13 && !colmap_exploded)
     {
       colmap_exploded = true;
-      
WorldObj::get_world()->get_colmap()->remove(bomber_radius.get_pixeldata(),
+      WorldObj::get_world()->get_colmap()->remove(bomber_radius,
                                                   
static_cast<int>(pingu->get_x () - (bomber_radius.get_width()/2)),
                                                   
static_cast<int>(pingu->get_y () - 16 - (bomber_radius.get_width()/2)));
-      
WorldObj::get_world()->get_gfx_map()->remove(bomber_radius_gfx.get_pixeldata(),
+      WorldObj::get_world()->get_gfx_map()->remove(bomber_radius_gfx,
                                                    
static_cast<int>(pingu->get_x () - (bomber_radius.get_width()/2)),
                                                    
static_cast<int>(pingu->get_y () - 16 - (bomber_radius.get_width()/2)));
     }

Modified: trunk/src/actions/bomber.hxx
===================================================================
--- trunk/src/actions/bomber.hxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/bomber.hxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -37,11 +37,11 @@
   bool colmap_exploded;
 
   static bool static_surface_loaded;
-  static CL_Surface bomber_radius;
-  static CL_Surface bomber_radius_gfx;
+  static CL_PixelBuffer bomber_radius;
+  static CL_PixelBuffer bomber_radius_gfx;
 
   Sprite     sprite;
-  CL_Surface explo_surf;
+  CL_Sprite  explo_surf;
 
 public:
   Bomber (Pingu* p);

Modified: trunk/src/actions/bridger.cxx
===================================================================
--- trunk/src/actions/bridger.cxx       2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/bridger.cxx       2004-05-09 16:44:16 UTC (rev 2322)
@@ -34,8 +34,8 @@
 
 // Initialise class static
 bool Bridger::static_surfaces_loaded = false;
-CL_Surface Bridger::brick_l;
-CL_Surface Bridger::brick_r;
+CL_PixelBuffer Bridger::brick_l;
+CL_PixelBuffer Bridger::brick_r;
 CL_Surface Bridger::static_surface;
 
 Bridger::Bridger (Pingu* p)
@@ -50,8 +50,8 @@
   if (!static_surfaces_loaded)
     {
       static_surface = PingusResource::load_surface ("Pingus/bridger0", 
"pingus");
-      brick_l = PingusResource::load_surface ("Other/brick_left", "pingus");
-      brick_r = PingusResource::load_surface ("Other/brick_right", "pingus");
+      brick_l = PingusResource::load_pixelbuffer("Other/brick_left", "pingus");
+      brick_r = PingusResource::load_pixelbuffer("Other/brick_right", 
"pingus");
       static_surfaces_loaded = true;
     }
 
@@ -236,21 +236,21 @@
 
   if (pingu->direction.is_right())
     {
-      WorldObj::get_world()->get_colmap()->put(brick_r.get_pixeldata(),
+      WorldObj::get_world()->get_colmap()->put(brick_r,
                                               static_cast<int>(pingu->get_x() 
+ 10 - brick_r.get_width()),
                                               static_cast<int>(pingu->get_y()),
                                               Groundtype::GP_BRIDGE);
-      WorldObj::get_world()->get_gfx_map()->put(brick_r.get_pixeldata(),
+      WorldObj::get_world()->get_gfx_map()->put(brick_r,
                                                static_cast<int>(pingu->get_x() 
+ 10 - brick_r.get_width()),
                                                
static_cast<int>(pingu->get_y()));
     }
   else
     {
-      WorldObj::get_world()->get_colmap()->put(brick_r.get_pixeldata(),
+      WorldObj::get_world()->get_colmap()->put(brick_r,
                                               static_cast<int>(pingu->get_x() 
- 10),
                                               static_cast<int>(pingu->get_y()),
                                               Groundtype::GP_BRIDGE);
-      WorldObj::get_world()->get_gfx_map()->put(brick_l.get_pixeldata(),
+      WorldObj::get_world()->get_gfx_map()->put(brick_l,
                                                static_cast<int>(pingu->get_x() 
- 10),
                                                
static_cast<int>(pingu->get_y()));
     }

Modified: trunk/src/actions/bridger.hxx
===================================================================
--- trunk/src/actions/bridger.hxx       2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/bridger.hxx       2004-05-09 16:44:16 UTC (rev 2322)
@@ -43,8 +43,8 @@
 
   static bool static_surfaces_loaded;
   static CL_Surface static_surface;
-  static CL_Surface brick_l;
-  static CL_Surface brick_r;
+  static CL_PixelBuffer brick_l;
+  static CL_PixelBuffer brick_r;
 
   int bricks;
   //int step;

Modified: trunk/src/actions/digger.cxx
===================================================================
--- trunk/src/actions/digger.cxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/digger.cxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -33,8 +33,8 @@
 
 Digger::Digger (Pingu* p)
   : PinguAction(p),
-    digger_radius(PingusResource::load_surface ("Other/digger_radius", 
"pingus")),
-    digger_radius_gfx(PingusResource::load_surface ("Other/digger_radius", 
"pingus")),
+    digger_radius(PingusResource::load_pixelbuffer("Other/digger_radius", 
"pingus")),
+    digger_radius_gfx(PingusResource::load_pixelbuffer("Other/digger_radius", 
"pingus")),
     sprite(Sprite (std::string("Pingus/digger") + to_string(pingu->get_owner 
()), "pingus")),
     digger_c(0)
 {
@@ -99,10 +99,10 @@
 void
 Digger::dig ()
 {
-  WorldObj::get_world()->get_colmap()->remove(digger_radius.get_pixeldata(),
+  WorldObj::get_world()->get_colmap()->remove(digger_radius,
                                              static_cast<int>(pingu->get_x() - 
(digger_radius_width / 2)),
                                              static_cast<int>(pingu->get_y() - 
digger_radius_height + 2));
-  
WorldObj::get_world()->get_gfx_map()->remove(digger_radius_gfx.get_pixeldata(),
+  WorldObj::get_world()->get_gfx_map()->remove(digger_radius_gfx,
                                               static_cast<int>(pingu->get_x () 
- (digger_radius_gfx_width / 2)),
                                               static_cast<int>(pingu->get_y() 
- digger_radius_gfx_height + 2));
   pingu->set_y(pingu->get_y() + 1);

Modified: trunk/src/actions/digger.hxx
===================================================================
--- trunk/src/actions/digger.hxx        2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/actions/digger.hxx        2004-05-09 16:44:16 UTC (rev 2322)
@@ -29,8 +29,8 @@
 class Digger : public PinguAction
 {
 private:
-  CL_Surface digger_radius;
-  CL_Surface digger_radius_gfx;
+  CL_PixelBuffer digger_radius;
+  CL_PixelBuffer digger_radius_gfx;
   Sprite sprite;
   int digger_c;
 

Modified: trunk/src/blitter.cxx
===================================================================
--- trunk/src/blitter.cxx       2004-05-09 16:20:24 UTC (rev 2321)
+++ trunk/src/blitter.cxx       2004-05-09 16:44:16 UTC (rev 2322)
@@ -232,67 +232,69 @@
 }
 
 void
-Blitter::put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
-                          int x, int y)
+Blitter::put_alpha_surface(CL_PixelBuffer target, CL_PixelBuffer source,
+                          int x_pos, int y_pos)
 {
-  int start_i;
-  unsigned char* tbuffer; // Target buffer
-  int twidth, theight, tpitch;
+  assert(target.get_format().get_depth() == 32);
 
-  unsigned char* sbuffer; // Source buffer
-  int swidth, sheight, spitch;
+  target.lock();
+  source.lock();
 
-  CL_Palette palette;
-  int x_offset, y_offset;
+  int swidth  = source.get_width();
+  int twidth  = target.get_width();
 
-  provider.lock();
-  sprovider.lock();
+  int start_x = std::max(0, -x_pos);
+  int start_y = std::max(0, -y_pos);
 
-  //  assert(sprovider.get_format().get_depth() == 8);
-  if (sprovider.get_format().get_depth() != 8)
-    {
-      sprovider.unlock ();
-      provider.unlock ();
-      PingusError::raise("Image has wrong color depth: " + 
to_string(sprovider.get_format().get_depth()));
-    }
-  //  assert(provider.get_pixel_format() == RGBA8888);
+  int end_x = std::min(swidth,  twidth  - x_pos);
+  int end_y = std::min(source.get_height(), target.get_height() - y_pos);
 
-  tbuffer = static_cast<unsigned char*>(provider.get_data());
-  sbuffer = static_cast<unsigned char*>(sprovider.get_data());
+  if (end_x - start_x <= 0 || end_y - start_y <= 0)
+    return;
 
-  palette = sprovider.get_palette();
-  
-  twidth  = provider.get_width();
-  theight = provider.get_height();
-  tpitch  = provider.get_pitch();
+  cl_uint8* target_buf = static_cast<cl_uint8*>(target.get_data());
+  cl_uint8* source_buf = static_cast<cl_uint8*>(source.get_data());
 
-  swidth  = sprovider.get_width();
-  sheight = sprovider.get_height();
-  spitch  = sprovider.get_pitch();
+  CL_Palette palette = source.get_palette();
 
-  if (y < 0)
-    y_offset = 0-y;
-  else
-    y_offset = 0;
+  if (source.get_format().has_colorkey())
+    {
+      unsigned int colorkey = source.get_format().get_colorkey();
 
-  if (x < 0)
-    x_offset = -x;
-  else
-    x_offset = 0;
+      for (int y = start_y; y < end_y; ++y)
+        {
+          cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos + 
start_x);
+          cl_uint8* sptr = source_buf + swidth*y + start_x;
 
-  for(int line=y_offset; line < sheight && (line + y) < theight; ++line) {
-    start_i = ((line + y) * tpitch) + (x*4);
+          for (int x = start_x; x < end_x; ++x)
+            { 
+              if (*sptr != colorkey)
+                *tptr = 0;
 
-    for(int i=start_i+(4*x_offset),j=line*spitch+x_offset;
-       i < start_i + (4*swidth) && (i-start_i+(x*4)) < (4*twidth); i+=4,++j) {
-      if (sbuffer[j]) {
-       tbuffer[i + 0] = 0;                                  // alpha
-      }
+              tptr += 4;
+              sptr += 1;
+            }
+        }
     }
-  }
+  else
+    {
+      for (int y = start_y; y < end_y; ++y)
+        {
+          cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos + 
start_x);
+          cl_uint8* sptr = source_buf + swidth*y + start_x;
 
-  sprovider.unlock();
-  provider.unlock();
+          for (int x = start_x; x < end_x; ++x)
+            { 
+              *tptr = 0;
+              
+              tptr += 4;
+              sptr += 1;
+            }
+        }
+    }
+  
+  source.unlock();
+  target.unlock();
 }
 
 void
@@ -345,7 +347,7 @@
             { 
               float a = color.get_alpha()/255.0f;
 
-              *tptr++ = Math::mid(0, int((1.0f - a) * *tptr + a * 
color.get_alpha()), 255);
+              *tptr++ = Math::mid(0, int(*tptr + a * color.get_alpha()), 255);
               *tptr++ = Math::mid(0, int((1.0f - a) * *tptr + a * 
color.get_blue()) , 255);
               *tptr++ = Math::mid(0, int((1.0f - a) * *tptr + a * 
color.get_green()), 255);
               *tptr++ = Math::mid(0, int((1.0f - a) * *tptr + a * 
color.get_red())  , 255);





reply via email to

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