pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.21,1.22 miner.cx


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.21,1.22 miner.cxx,1.16,1.17 miner.hxx,1.11,1.12
Date: 22 Oct 2002 00:07:58 -0000

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

Modified Files:
        bomber.cxx miner.cxx miner.hxx 
Log Message:
Gervases bomber and miner patches

Index: bomber.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/bomber.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- bomber.cxx  13 Oct 2002 20:25:00 -0000      1.21
+++ bomber.cxx  22 Oct 2002 00:07:56 -0000      1.22
@@ -80,63 +80,17 @@
 {
   sprite.update ();
 
-  Vector newp = pingu->get_velocity();
-
-  // Subtract velocity due to the fact that the Pingu is ballooning up before
-  // applying it.
-  newp.y -= 1.0f;
-
-  // Apply all forces
-  pingu->set_velocity(ForcesHolder::apply_forces(pingu->get_pos(), newp));
-    
-  newp = pingu->get_velocity();
-
-  //pout(PINGUS_DEBUG_ACTIONS) << "x" << newp.x << std::endl;
-  //pout(PINGUS_DEBUG_ACTIONS) << "y" << newp.y << std::endl;
-  
-  // If going right
-  if (newp.x > 0)
-    {
-      // Move Pingu gradually to the right.  As the velocity may be a fraction,
-      // stop within 1 unit.
-      while (newp.x >= 1 && rel_getpixel(1, 0) == Groundtype::GP_NOTHING)
-       {
-         pingu->set_x(pingu->get_x() + 1);
-         newp.x--;
-       }
-    }
-  else
-    {
-      // Move Pingu gradually to the left.  As the velocity may be a fraction,
-      // stop within 1 unit.
-      while (newp.x <= -1 && rel_getpixel(-1, 0) == Groundtype::GP_NOTHING)
-       {
-         pingu->set_x(pingu->get_x() - 1);
-         newp.x++;
-       }
-    }
+  // Move the Bomber according to the forces that currently exist, subtracting
+  // the velocity due to the fact that the Pingu is ballooning up.  Best to
+  // make it -1.0 so that exploding Walkers etc... remain "stationary."
+  move_with_forces (0.0, -1.0);
 
-  // If going down
-  if (newp.y > 0)
-    {
-      // Move Pingu down gradually.  As the velocity may be a fraction,
-      // stop within 1 unit.
-      while (newp.y >= 1 && rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
-       {
-         pingu->set_y(pingu->get_y() + 1);
-         newp.y--;
-       }
-    }
-  else
+  // If the Bomber hasn't 'exploded' yet and it has hit Water or Lava
+  if (sprite.get_frame () <= 9 && (rel_getpixel(0, -1) == Groundtype::GP_WATER
+      || rel_getpixel(0, -1) == Groundtype::GP_LAVA)) 
     {
-      // Move Pingu up gradually.  As the velocity may be a fraction,
-      // stop within 1 unit.
-      while (newp.y <= -1
-             && rel_getpixel(0, pingu_height) == Groundtype::GP_NOTHING)
-       {
-         pingu->set_y(pingu->get_y() - 1);
-         newp.y++;
-       }
+      pingu->set_action(Actions::Drown);
+      return;
     }
 
   if (sprite.get_frame () > 9 && !sound_played) {

Index: miner.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/miner.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- miner.cxx   13 Oct 2002 20:25:00 -0000      1.16
+++ miner.cxx   22 Oct 2002 00:07:56 -0000      1.17
@@ -36,6 +36,9 @@
     slow_count(0)
 {
   sprite.set_align_center_bottom();
+
+  miner_radius_width = miner_radius.get_width();
+  miner_radius_gfx_width = miner_radius_gfx.get_width();
 }
 
 void
@@ -55,11 +58,11 @@
       if (!(slow_count % 3))
        {
          
WorldObj::get_world()->get_colmap()->remove(miner_radius.get_provider(), 
-                                                     
static_cast<int>(pingu->get_x() - 16 + pingu->direction), 
-                                                     
static_cast<int>(pingu->get_y() - 31));
+                                                     
static_cast<int>(pingu->get_x() - (miner_radius_width / 2) + pingu->direction), 
+                                                     
static_cast<int>(pingu->get_y() - miner_radius_width + 1) );
          
WorldObj::get_world()->get_gfx_map()->remove(miner_radius_gfx.get_provider(), 
-                                                      
static_cast<int>(pingu->get_x() - 16 + pingu->direction),
-                                                      
static_cast<int>(pingu->get_y() - 31));
+                                                      
static_cast<int>(pingu->get_x() - (miner_radius_gfx_width / 2) + 
pingu->direction),
+                                                      
static_cast<int>(pingu->get_y() - miner_radius_gfx_width + 1) );
        }
 
       pingu->set_pos(pingu->get_x() + pingu->direction, pingu->get_y() + 1);
@@ -68,22 +71,22 @@
   if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
     {
       WorldObj::get_world()->get_colmap()->remove(miner_radius, 
-                                                 
static_cast<int>(pingu->get_x() - 16 + pingu->direction),
-                                                 static_cast<int>(pingu->get_y 
() - 29));
+                                                 
static_cast<int>(pingu->get_x() - (miner_radius_width / 2) + pingu->direction), 
+                                                 
static_cast<int>(pingu->get_y() - miner_radius_width + 3) );
       WorldObj::get_world()->get_gfx_map()->remove(miner_radius_gfx,
-                                                  
static_cast<int>(pingu->get_x() - 16 + pingu->direction),
-                                                  
static_cast<int>(pingu->get_y() - 29));
+                                                  
static_cast<int>(pingu->get_x() - (miner_radius_width / 2) + pingu->direction), 
+                                                  
static_cast<int>(pingu->get_y() - miner_radius_width + 3) );
       pingu->set_action(Actions::Walker);
     }
   else if (rel_getpixel(0, -1) == Groundtype::GP_SOLID)
     {
       PingusSound::play_sound("sounds/chink.wav");
       WorldObj::get_world()->get_colmap ()->remove(miner_radius,
-                                                  
static_cast<int>(pingu->get_x() - 16 + pingu->direction),
-                                                  
static_cast<int>(pingu->get_y() - 31));
+                                                  
static_cast<int>(pingu->get_x() - (miner_radius_width / 2) + pingu->direction), 
+                                                  
static_cast<int>(pingu->get_y() - miner_radius_width + 1) );
       WorldObj::get_world()->get_gfx_map()->remove(miner_radius_gfx,
-                                                  
static_cast<int>(pingu->get_x() - 16 + pingu->direction),
-                                                  
static_cast<int>(pingu->get_y() - 31));
+                                                  
static_cast<int>(pingu->get_x() - (miner_radius_gfx_width / 2) + 
pingu->direction),
+                                                  
static_cast<int>(pingu->get_y() - miner_radius_gfx_width + 1) );
       pingu->set_action(Actions::Walker);
     }
 }

Index: miner.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/miner.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- miner.hxx   13 Oct 2002 16:40:01 -0000      1.11
+++ miner.hxx   22 Oct 2002 00:07:56 -0000      1.12
@@ -32,6 +32,13 @@
   CL_Surface miner_radius_gfx;
   Sprite sprite;
   int slow_count;
+
+  /** Width of the miner_radius surface */
+  unsigned int miner_radius_width;
+
+  /** Width of the miner_radius_gfx surface */
+  unsigned int miner_radius_gfx_width;
+
 public:
   Miner (Pingu* p);
   virtual ~Miner () {}





reply via email to

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