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 climber.cxx,1.15,1.16 faller.


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/actions climber.cxx,1.15,1.16 faller.cxx,1.27,1.28 jumper.cxx,1.14,1.15 miner.cxx,1.13,1.14 slider.cxx,1.12,1.13 walker.cxx,1.26,1.27
Date: 4 Oct 2002 11:38:31 -0000

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

Modified Files:
        climber.cxx faller.cxx jumper.cxx miner.cxx slider.cxx 
        walker.cxx 
Log Message:
- removed a few FIXME
- some minor clean/speed up


Index: climber.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/climber.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- climber.cxx 3 Oct 2002 12:33:09 -0000       1.15
+++ climber.cxx 4 Oct 2002 11:38:29 -0000       1.16
@@ -112,10 +112,7 @@
 bool
 Climber::change_allowed(ActionName new_action)
 {
-  if (new_action == Actions::Floater)
-    return true;
-  else
-    return false;
+  return (new_action == Actions::Floater);
 }
 
 } // namespace Actions

Index: faller.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/faller.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- faller.cxx  3 Oct 2002 00:47:05 -0000       1.27
+++ faller.cxx  4 Oct 2002 11:38:29 -0000       1.28
@@ -44,19 +44,19 @@
   // FIXME: we can save some cpu cycles & memory if we do this when it
   // is necessary
   tumbler = Sprite("Pingus/tumble" + to_string(pingu->get_owner()), "pingus");
-  tumbler.set_align_center_bottom ();
+  tumbler.set_align_center_bottom();
 }
 
 void
 Faller::update ()
 {
-  tumbler.update ();
-  faller.update ();
+  tumbler.update();
+  faller.update();
 
   // Pingu stands on ground
   if (rel_getpixel(0, -1) !=  Groundtype::GP_NOTHING)
     { 
-      pingu->set_action (Actions::Walker);
+      pingu->set_action(Actions::Walker);
       return;
     }
 
@@ -72,7 +72,7 @@
   
   // Update x and y by moving the penguin to it's target *slowly*
   // and checking if the penguin has hit the bottom at each loop
-  while(rel_getpixel(0, -1) == Groundtype::GP_NOTHING
+  while (  rel_getpixel(0, -1) == Groundtype::GP_NOTHING
        && (fabs(newp.x) >= 1 || fabs(newp.y) >= 1))
     {
       if (fabs(newp.x) >= 1)
@@ -153,24 +153,14 @@
 Faller::is_tumbling () const
 {
   // If we are going fast enough to get smashed, start tumbling
-  if (fabs(pingu->get_velocity().x) > deadly_velocity
-      || fabs(pingu->get_velocity().y) > deadly_velocity)
-    {
-      return true;
-    }
-  else
-    {
-      return false;
-    }
+  return (   fabs(pingu->get_velocity().x) > deadly_velocity
+          || fabs(pingu->get_velocity().y) > deadly_velocity);
 }
 
 bool
 Faller::change_allowed (ActionName new_action)
 {
-  if (new_action == Actions::Floater)
-    return true;
-  else
-    return false;
+  return (new_action == Actions::Floater);
 }
 
 } // namespace Actions

Index: jumper.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/jumper.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- jumper.cxx  1 Oct 2002 19:53:45 -0000       1.14
+++ jumper.cxx  4 Oct 2002 11:38:29 -0000       1.15
@@ -35,25 +35,22 @@
 {
   sprite = Sprite("Pingus/jumper" + to_string(pingu->get_owner ()),
                  "pingus");
-  sprite.set_align_center_bottom ();
+  sprite.set_align_center_bottom();
 }
 
 void 
 Jumper::draw (GraphicContext& gc)
 {
-  gc.draw(sprite, pingu->get_pos ());
+  gc.draw(sprite, pingu->get_pos());
 }
 
 void
 Jumper::update ()
 {
-  //FIXME Vector
-  Vector temp(pingu->get_velocity());
-    
   if (pingu->direction.is_right()) {
-    pingu->set_velocity(temp + Vector(10.0, -10.0));
+    pingu->set_velocity(pingu->get_velocity() + Vector(10.0, -10.0));
   } else {
-    pingu->set_velocity(temp + Vector(-10.0, -10.0));
+    pingu->set_velocity(pingu->get_velocity() + Vector(-10.0, -10.0));
   }
 
   // Move the pingu in the air, so that it can start 'falling'

Index: miner.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/miner.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- miner.cxx   1 Oct 2002 19:53:45 -0000       1.13
+++ miner.cxx   4 Oct 2002 11:38:29 -0000       1.14
@@ -28,75 +28,75 @@
 
 namespace Actions {
 
-  Miner::Miner()
-  {
-  }
+Miner::Miner()
+{
+}
 
-  void
-  Miner::init(void)
-  {
-    miner_radius = PingusResource::load_surface ("Other/bash_radius", 
"pingus");
-    miner_radius_gfx = PingusResource::load_surface ("Other/bash_radius_gfx", 
"pingus");
-    sprite = Sprite ("Pingus/miner0", "pingus", 20.0f);
-    sprite.set_align_center_bottom ();
-    slow_count = 0;
-  }
+void
+Miner::init (void)
+{
+  miner_radius = PingusResource::load_surface("Other/bash_radius", "pingus");
+  miner_radius_gfx = PingusResource::load_surface("Other/bash_radius_gfx", 
"pingus");
+  sprite = Sprite("Pingus/miner0", "pingus", 20.0f);
+  sprite.set_align_center_bottom();
+  slow_count = 0;
+}
 
-  void
-  Miner::update()
-  {
-    sprite.update ();
-  
-    // FIXME: Direction handling is ugly
-    if (pingu->direction.is_left ())
-      sprite.set_direction (Sprite::LEFT);
-    else
-      sprite.set_direction (Sprite::RIGHT);
+void
+Miner::update ()
+{
+  sprite.update();
 
-    ++slow_count;
-    if (slow_count % 4  == 0) 
-      {
-        if (slow_count % 3 == 0) 
-         {
-           
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));
-           
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));
-         }
+  // FIXME: Direction handling is ugly
+  if (pingu->direction.is_left())
+    sprite.set_direction(Sprite::LEFT);
+  else
+    sprite.set_direction(Sprite::RIGHT);
 
-        pingu->set_pos(pingu->get_x() + pingu->direction, pingu->get_y() + 1);
-      }
-  
-    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));
-        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));
-        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));
-        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));
-        pingu->set_action(Actions::Walker);
-      }
-  }
+  ++slow_count;
+  if (!(slow_count % 4))
+    {
+      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));
+         
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));
+       }
 
-  void 
-  Miner::draw (GraphicContext& gc)
-  {
-    gc.draw (sprite, pingu->get_pos());
-  }
+      pingu->set_pos(pingu->get_x() + pingu->direction, pingu->get_y() + 1);
+    }
+
+  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));
+      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));
+      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));
+      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));
+      pingu->set_action(Actions::Walker);
+    }
+}
+
+void 
+Miner::draw (GraphicContext& gc)
+{
+  gc.draw(sprite, pingu->get_pos());
+}
 
 } // namespace Actions
 

Index: slider.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/slider.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- slider.cxx  1 Oct 2002 19:53:45 -0000       1.12
+++ slider.cxx  4 Oct 2002 11:38:29 -0000       1.13
@@ -32,7 +32,7 @@
 void
 Slider::init (void)
 {
-  sprite = Sprite("Pingus/slider" + to_string(pingu->get_owner ()),
+  sprite = Sprite("Pingus/slider" + to_string(pingu->get_owner()),
                  "pingus");
   sprite.set_align_center_bottom();
   speed = 10;
@@ -46,7 +46,7 @@
   else
     sprite.set_direction(Sprite::RIGHT);
 
-  sprite.update ();
+  sprite.update();
 
   for (int i = 0; i < speed; ++i)
     {
@@ -56,12 +56,10 @@
        {
          speed = (speed > 5) ? 5 : speed;
 
-         //FIXME Vector
-         Vector temp(pingu->get_velocity());
          if (pingu->direction.is_right()) {
-           pingu->set_velocity(temp + Vector(speed, 0.0));
+           pingu->set_velocity(pingu->get_velocity() + Vector(speed, 0.0));
          } else {
-           pingu->set_velocity(temp + Vector(-speed, 0.0));
+           pingu->set_velocity(pingu->get_velocity() + Vector(-speed, 0.0));
          }
 
          pingu->set_action(Actions::Walker);
@@ -76,7 +74,7 @@
 void
 Slider::draw (GraphicContext& gc)
 {
-  gc.draw (sprite, pingu->get_pos() + Vector(0, -2));
+  gc.draw(sprite, pingu->get_pos() + Vector(0, -2));
 }
 
 } // namespace Actions

Index: walker.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/walker.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- walker.cxx  3 Oct 2002 00:47:05 -0000       1.26
+++ walker.cxx  4 Oct 2002 11:38:29 -0000       1.27
@@ -123,8 +123,8 @@
       bool found_next_step = false;
       for (y_inc = -max_steps; y_inc <= max_steps; ++y_inc)
        {// up/down-hill scan
-         if ((   rel_getpixel(1, y_inc)     == Groundtype::GP_NOTHING
-                 || rel_getpixel(1, y_inc)     == Groundtype::GP_BRIDGE) // 
FIXME: This causes a rather huge step
+         if ((  rel_getpixel(1, y_inc)     == Groundtype::GP_NOTHING
+              || rel_getpixel(1, y_inc)     == Groundtype::GP_BRIDGE) // 
FIXME: This causes a rather huge step
              && rel_getpixel(1, y_inc - 1) != Groundtype::GP_NOTHING)
            { // FIXME:
              found_next_step = true;





reply via email to

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