pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldobjs hammer.cxx,1.7,1.8 hammer.h


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldobjs hammer.cxx,1.7,1.8 hammer.hxx,1.7,1.8
Date: 1 Oct 2002 23:40:21 -0000

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

Modified Files:
        hammer.cxx hammer.hxx 
Log Message:
- cleaned up the hammer a bit and broke it, needs more fixing

Index: hammer.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/hammer.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- hammer.cxx  1 Oct 2002 23:10:41 -0000       1.7
+++ hammer.cxx  1 Oct 2002 23:40:19 -0000       1.8
@@ -27,12 +27,10 @@
 
 namespace WorldObjs {
 
-Hammer::Hammer (const WorldObjsData::HammerData& data_) : data(new 
WorldObjsData::HammerData(data_)),
-                                                          
particle_thrown(false)
+Hammer::Hammer (const WorldObjsData::HammerData& data_) 
+  : data(new WorldObjsData::HammerData(data_))
 {
-  data->counter.set_size(data->surface.get_num_frames());
-  data->counter.set_type(GameCounter::ping_pong);
-  data->counter.set_speed(1);
+  sprite = Sprite("Traps/hammer", "traps");
 }
 
 Hammer::~Hammer ()
@@ -49,43 +47,29 @@
 void 
 Hammer::draw (GraphicContext& gc)
 {
-  gc.draw (data->surface, data->pos, data->counter.value());
+  gc.draw (sprite, data->pos);
 }
 
 void
 Hammer::update ()
 {
-  if ( !data->counter) 
-    particle_thrown = false;
-
-  PinguHolder* holder = world->get_pingu_p ();
-  for (PinguIter pingu = holder->begin (); pingu != holder->end (); ++pingu){
-    catch_pingu(*pingu);
-  }
-
-  if ( !particle_thrown && data->counter == 
static_cast<int>(data->surface.get_num_frames() - 3)) {
-    particle_thrown = true;
-    /*
-      for(int i=0; i < 5; ++i)
-      particle->add_particle(new GroundParticle(x_pos + 67 + rand() % 40 - 20 ,
-      y_pos + 177,
-      frand() * 2 - 1,
-      frand() * - 1.5));
-    */
-  }
-  ++data->counter;
-}
+  sprite.update();
 
-void
-Hammer::catch_pingu (Pingu* pingu)
-{
-  if (pingu->get_action()->get_type() != Actions::Smashed)
+  if (sprite.finished())
     {
-      if (data->counter >= static_cast<int>(data->surface.get_num_frames() - 
3)) {
-       if (pingu->get_x() > data->pos.x + 55  && pingu->get_x() < data->pos.x 
+ 77
-           && pingu->get_y() > data->pos.y + 146 && pingu->get_y() < 
data->pos.y + 185)
-         pingu->set_action(Actions::Smashed);
-      }
+      PinguHolder* holder = world->get_pingu_p ();
+
+      for (PinguIter pingu_it = holder->begin (); pingu_it != holder->end (); 
++pingu_it) 
+       {
+         Pingu* pingu = *pingu_it;
+         if (pingu->get_action()->get_type() != Actions::Splashed)
+           {
+             if (pingu->get_x() > data->pos.x + 55  && pingu->get_x() < 
data->pos.x + 77
+                   && pingu->get_y() > data->pos.y + 146 && pingu->get_y() < 
data->pos.y + 185)
+                 pingu->set_action(Actions::Splashed);
+           }
+       }
+      sprite.reset();
     }
 }
 

Index: hammer.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/hammer.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- hammer.hxx  1 Oct 2002 19:53:46 -0000       1.7
+++ hammer.hxx  1 Oct 2002 23:40:19 -0000       1.8
@@ -20,6 +20,7 @@
 #ifndef HEADER_PINGUS_WORLDOBJS_HAMMER_HXX
 #define HEADER_PINGUS_WORLDOBJS_HAMMER_HXX
 
+#include "../sprite.hxx"
 #include "../worldobj.hxx"
 
 namespace WorldObjsData {
@@ -34,7 +35,7 @@
 {
 private:
   WorldObjsData::HammerData* const data;
-  bool particle_thrown;
+  Sprite sprite;
     
 public:
   Hammer (const WorldObjsData::HammerData& data_);
@@ -44,9 +45,6 @@
 
   void draw (GraphicContext& gc);
   void update ();
-
-protected:
-  void catch_pingu (Pingu*);
 
 private:
   Hammer (const Hammer&);





reply via email to

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