pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] rev 2338 - in trunk/src: . actions gui input input/buttons


From: Ingo Ruhnke
Subject: [Pingus-CVS] rev 2338 - in trunk/src: . actions gui input input/buttons worldmap worldobjsdata
Date: Thu, 24 Jun 2004 00:13:53 +0200

Author: grumbel
Date: 2004-06-24 00:13:52 +0200 (Thu, 24 Jun 2004)
New Revision: 2338

Modified:
   trunk/src/actions/basher.cxx
   trunk/src/actions/boarder.cxx
   trunk/src/actions/faller.cxx
   trunk/src/actions/miner.cxx
   trunk/src/actions/walker.cxx
   trunk/src/gui/game_delta.hxx
   trunk/src/gui/screen_manager.cxx
   trunk/src/input/button.hxx
   trunk/src/input/buttons/double_button.cxx
   trunk/src/input/buttons/mouse_button.cxx
   trunk/src/input/controller.cxx
   trunk/src/input/controller.hxx
   trunk/src/input/event.hxx
   trunk/src/input/event_fwd.hxx
   trunk/src/plf.cxx
   trunk/src/state_sprite.cxx
   trunk/src/state_sprite.hxx
   trunk/src/worldmap/pingus.cxx
   trunk/src/worldobjsdata/worldobj_group_data.cxx
Log:
- changed statesprite to use [] instead of ()
- fixed polling vs. events issue in the input code

Modified: trunk/src/actions/basher.cxx
===================================================================
--- trunk/src/actions/basher.cxx        2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/actions/basher.cxx        2004-06-23 22:13:52 UTC (rev 2338)
@@ -55,13 +55,13 @@
 void
 Basher::draw (GraphicContext& gc)
 {
-  gc.draw(sprite(pingu->direction), pingu->get_pos());
+  gc.draw(sprite[pingu->direction], pingu->get_pos());
 }
 
 void
 Basher::update ()
 {
-  sprite(pingu->direction).update();
+  sprite[pingu->direction].update();
 
   ++basher_c;
   if (basher_c % 3 == 0)
@@ -94,8 +94,8 @@
              if (basher_c % 2 == 0)
                bash();
            }
-         else if (sprite(pingu->direction).get_current_frame() 
-                   / float(sprite(pingu->direction).get_frame_count()) > 0.6f) 
+         else if (sprite[pingu->direction].get_current_frame() 
+                   / float(sprite[pingu->direction].get_frame_count()) > 0.6f) 
            { // FIXME: EVIL! Engine must not relay on graphic
              pingu->set_action(Actions::Walker);
            }

Modified: trunk/src/actions/boarder.cxx
===================================================================
--- trunk/src/actions/boarder.cxx       2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/actions/boarder.cxx       2004-06-23 22:13:52 UTC (rev 2338)
@@ -39,7 +39,7 @@
 void
 Boarder::update ()
 {
-  sprite(pingu->direction).update();
+  sprite[pingu->direction].update();
 
   if (on_ground())
     {
@@ -79,7 +79,7 @@
 void
 Boarder::draw (GraphicContext& gc)
 {
-  gc.draw(sprite(pingu->direction), pingu->get_pos ());
+  gc.draw(sprite[pingu->direction], pingu->get_pos ());
 }
 
 bool

Modified: trunk/src/actions/faller.cxx
===================================================================
--- trunk/src/actions/faller.cxx        2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/actions/faller.cxx        2004-06-23 22:13:52 UTC (rev 2338)
@@ -49,8 +49,8 @@
 void
 Faller::update ()
 {
-  tumbler(pingu->direction).update();
-  faller(pingu->direction).update();
+  tumbler[pingu->direction].update();
+  faller[pingu->direction].update();
 
   // Pingu stands on ground
   if (rel_getpixel(0, -1) !=  Groundtype::GP_NOTHING)
@@ -148,9 +148,9 @@
 Faller::draw (GraphicContext& gc)
 {
   if (is_tumbling()) {
-    gc.draw(tumbler(pingu->direction), pingu->get_pos ());
+    gc.draw(tumbler[pingu->direction], pingu->get_pos ());
   } else {
-    gc.draw(faller(pingu->direction), pingu->get_pos ());
+    gc.draw(faller[pingu->direction], pingu->get_pos ());
   }
 }
 

Modified: trunk/src/actions/miner.cxx
===================================================================
--- trunk/src/actions/miner.cxx 2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/actions/miner.cxx 2004-06-23 22:13:52 UTC (rev 2338)
@@ -45,7 +45,7 @@
 void
 Miner::update ()
 {
-  sprite(pingu->direction).update();
+  sprite[pingu->direction].update();
 
   ++slow_count;
   if (!(slow_count % 4))
@@ -95,7 +95,7 @@
 void
 Miner::draw (GraphicContext& gc)
 {
-  gc.draw(sprite(pingu->direction), pingu->get_pos());
+  gc.draw(sprite[pingu->direction], pingu->get_pos());
 }
 
 } // namespace Actions

Modified: trunk/src/actions/walker.cxx
===================================================================
--- trunk/src/actions/walker.cxx        2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/actions/walker.cxx        2004-06-23 22:13:52 UTC (rev 2338)
@@ -46,8 +46,8 @@
 Walker::update ()
 {
   // update the sprite
-  walker(pingu->direction).update(0.033);
-  floaterlayer(pingu->direction).update(0.033);
+  walker[pingu->direction].update(0.033);
+  floaterlayer[pingu->direction].update(0.033);
 
   Vector last_pos = pingu->get_pos();
 
@@ -207,11 +207,11 @@
 void
 Walker::draw (GraphicContext& gc)
 {
-  gc.draw(walker(pingu->direction), pingu->get_pos());
+  gc.draw(walker[pingu->direction], pingu->get_pos());
 
   if (pingu->get_fall_action() && pingu->get_fall_action()->get_type() == 
Actions::Floater)
     {
-      gc.draw(floaterlayer(pingu->direction), pingu->get_pos());
+      gc.draw(floaterlayer[pingu->direction], pingu->get_pos());
     }
 }
 

Modified: trunk/src/gui/game_delta.hxx
===================================================================
--- trunk/src/gui/game_delta.hxx        2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/gui/game_delta.hxx        2004-06-23 22:13:52 UTC (rev 2338)
@@ -22,7 +22,7 @@
 
 #include <list>
 #include "../delta_manager.hxx"
-#include "../input/event_fwd.hxx"
+#include "../input/event.hxx"
 
 namespace Pingus {
 
@@ -37,7 +37,7 @@
 
   /** Reference to the event list from the controller, we must not
       delete the Event* */
-  const Input::EventLst& events;
+  Input::EventLst events;
 
 public:
   /** Construct a GameDelta with both time and events */

Modified: trunk/src/gui/screen_manager.cxx
===================================================================
--- trunk/src/gui/screen_manager.cxx    2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/gui/screen_manager.cxx    2004-06-23 22:13:52 UTC (rev 2338)
@@ -88,12 +88,14 @@
       CL_System::keep_alive ();
 
       // Get new events from ClanLib
-      input_controller->update (time_delta);
+      input_controller->update(time_delta);
 
       // Fill the delta with values
       GameDelta delta(time_delta, delta_manager.get_absolute(),
-                      input_controller->get_events ());
+                      input_controller->get_events());
 
+      input_controller->clear();
+
       last_screen = get_current_screen();
 
       // Most likly the screen will get changed in this update call

Modified: trunk/src/input/button.hxx
===================================================================
--- trunk/src/input/button.hxx  2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/input/button.hxx  2004-06-23 22:13:52 UTC (rev 2338)
@@ -20,6 +20,7 @@
 #ifndef HEADER_PINGUS_INPUT_BUTTON_HXX
 #define HEADER_PINGUS_INPUT_BUTTON_HXX
 
+#include <ClanLib/signals.h>
 #include "../pingus.hxx"
 
 namespace Pingus {
@@ -36,6 +37,13 @@
   virtual bool is_pressed ()      const =0;
   virtual void update     (float)       =0;
 
+  CL_Signal_v0& sig_button_down() { return button_down; }
+  CL_Signal_v0& sig_button_up() { return button_up; }
+
+protected:
+  CL_Signal_v0 button_down; 
+  CL_Signal_v0 button_up; 
+
 private:
   Button (const Button&);
   Button& operator= (const Button&);

Modified: trunk/src/input/buttons/double_button.cxx
===================================================================
--- trunk/src/input/buttons/double_button.cxx   2004-06-17 01:12:12 UTC (rev 
2337)
+++ trunk/src/input/buttons/double_button.cxx   2004-06-23 22:13:52 UTC (rev 
2338)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "../event_fwd.hxx"
 #include "double_button.hxx"
 
 namespace Pingus {

Modified: trunk/src/input/buttons/mouse_button.cxx
===================================================================
--- trunk/src/input/buttons/mouse_button.cxx    2004-06-17 01:12:12 UTC (rev 
2337)
+++ trunk/src/input/buttons/mouse_button.cxx    2004-06-23 22:13:52 UTC (rev 
2338)
@@ -51,18 +51,24 @@
   switch (button)
     {
     case 0:
-      if (signal.id == CL_MOUSE_LEFT)
+      if (signal.id == CL_MOUSE_LEFT) {
         pressed = true;
+        button_down();
+      }
       break;
             
     case 1:
-      if (signal.id == CL_MOUSE_MIDDLE)
+      if (signal.id == CL_MOUSE_MIDDLE) {
         pressed = true;
+        button_down();
+      }
       break;
             
     case 2:
-      if (signal.id == CL_MOUSE_RIGHT)
+      if (signal.id == CL_MOUSE_RIGHT) {
         pressed = true;
+        button_down();
+      }
       break;
             
     default: // only three buttons support so far
@@ -76,18 +82,24 @@
   switch (button)
     {
     case 0:
-      if (signal.id == CL_MOUSE_LEFT)
+      if (signal.id == CL_MOUSE_LEFT) {
         pressed = false;
+        button_up();
+      }
       break;
             
     case 1:
-      if (signal.id == CL_MOUSE_MIDDLE)
+      if (signal.id == CL_MOUSE_MIDDLE) {
         pressed = false;
+        button_up();
+      }
       break;
             
     case 2:
-      if (signal.id == CL_MOUSE_RIGHT)
+      if (signal.id == CL_MOUSE_RIGHT) {
         pressed = false;
+        button_up();
+      }
       break;
             
     default: // only three buttons support so far

Modified: trunk/src/input/controller.cxx
===================================================================
--- trunk/src/input/controller.cxx      2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/input/controller.cxx      2004-06-23 22:13:52 UTC (rev 2338)
@@ -82,31 +82,31 @@
         scroller = 
ScrollerFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "primary-button"))
-        buttons[primary].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[primary] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "secondary-button"))
-        buttons[secondary].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[secondary] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "pause-button"))
-        buttons[pause].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[pause] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "fast-forward-button"))
-        buttons[fast_forward].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[fast_forward] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "armageddon-button"))
-        buttons[armageddon].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[armageddon] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "escape-button"))
-        buttons[escape].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[escape] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "action-buttons"))
         create_action_buttons(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "action-up"))
-        buttons[action_up].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[action_up] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else if (XMLhelper::equal_str(cur->name, "action-down"))
-        buttons[action_down].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[action_down] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
 
       else
         PingusError::raise(std::string("Unkown Element in Controller Config: 
") + ((cur->name) ? reinterpret_cast<const char*>(cur->name) : ""));
@@ -133,54 +133,57 @@
 
   if (!buttons.count(primary))
     {
-      buttons[primary].first = new DummyButton;
+      buttons[primary] = new DummyButton;
       pwarn << "Controller: No primary button - inserting dummy" << std::endl;
     }
 
   if (!buttons.count(secondary))
     {
-      buttons[secondary].first = new DummyButton;
+      buttons[secondary] = new DummyButton;
       pwarn << "Controller: No secondary button - inserting dummy" << 
std::endl;
     }
 
   if (!buttons.count(pause))
     {
-      buttons[pause].first = new DummyButton;
+      buttons[pause] = new DummyButton;
       pwarn << "Controller: No pause button - inserting dummy" << std::endl;
     }
 
   if (!buttons.count(fast_forward))
     {
-      buttons[fast_forward].first = new DummyButton;
+      buttons[fast_forward] = new DummyButton;
       pwarn << "Controller: No fast_forward button - inserting dummy" << 
std::endl;
     }
 
   if (!buttons.count(armageddon))
     {
-      buttons[armageddon].first = new DummyButton;
+      buttons[armageddon] = new DummyButton;
       pwarn << "Controller: No armageddon button - inserting dummy" << 
std::endl;
     }
 
   if (!buttons.count(escape))
     {
-      buttons[escape].first = new DummyButton;
+      buttons[escape] = new DummyButton;
       pwarn << "Controller: No escape button - inserting dummy" << std::endl;
     }
 
   if (!buttons.count(action_up))
     {
-      buttons[action_up].first = new DummyButton;
+      buttons[action_up] = new DummyButton;
       pwarn << "Controller: No action up button - inserting dummy" << 
std::endl;
     }
 
   if (!buttons.count(action_down))
     {
-      buttons[action_down].first = new DummyButton;
+      buttons[action_down] = new DummyButton;
       pwarn << "Controller: No action down button - inserting dummy" << 
std::endl;
     }
 
-  for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it = 
buttons.begin(); it != buttons.end(); ++it)
-    it->second.second = it->second.first->is_pressed();
+  for (std::map<ButtonName, Button*>::iterator it = buttons.begin(); it != 
buttons.end(); ++it)
+    {
+      slots.push_back(it->second->sig_button_down().connect(this, 
&Controller::on_button_down, it->first));
+      slots.push_back(it->second->sig_button_up().connect(this, 
&Controller::on_button_up, it->first));
+    }
 }
 
 Controller::~Controller ()
@@ -188,8 +191,8 @@
   delete scroller;
   delete standard_pointer;
 
-  for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it = 
buttons.begin(); it != buttons.end(); ++it)
-    delete it->second.first;
+  for (std::map<ButtonName, Button*>::iterator it = buttons.begin(); it != 
buttons.end(); ++it)
+    delete it->second;
 }
 
 void
@@ -206,7 +209,7 @@
         }
 
       if (XMLhelper::equal_str(cur->name, "action-button"))
-        buttons[static_cast<ButtonName>(action_1 + count)].first = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+        buttons[static_cast<ButtonName>(action_1 + count)] = 
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
       else
         PingusError::raise(std::string("Wrong Element in Controller Config 
(action-buttons): ") + reinterpret_cast<const char*>(cur->name));
 
@@ -218,15 +221,15 @@
 void
 Controller::update (float delta)
 {
-  events.clear ();
-
   scroller        ->update(delta);
   standard_pointer->update(delta);
 
-  for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it = 
buttons.begin(); it != buttons.end(); ++it)
-    it->second.first->update(delta);
-
-  if (std_pointer_x != standard_pointer->get_x_pos() || std_pointer_y != 
standard_pointer->get_y_pos())
+  for (std::map<ButtonName, Button*>::iterator it = buttons.begin(); it != 
buttons.end(); ++it)
+    it->second->update(delta);
+  
+  // FIXME: Busy checking of button status and other events is *VERY EVIL*
+  if (std_pointer_x != standard_pointer->get_x_pos()
+      || std_pointer_y != standard_pointer->get_y_pos())
     {
       std_pointer_x = standard_pointer->get_x_pos();
       std_pointer_y = standard_pointer->get_y_pos();
@@ -234,29 +237,38 @@
       events.push_back(makePointerEvent(standard, std_pointer_x, 
std_pointer_y));
     }
 
+  // FIXME: Busy checking of button status and other events is *VERY EVIL*
   if (scroller->get_x_delta() || scroller->get_y_delta())
     events.push_back(makeScrollEvent(scroller->get_x_delta(), 
scroller->get_y_delta()));
+}
 
-  for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it = 
buttons.begin(); it != buttons.end(); ++it)
-    if (it->second.first->is_pressed() != it->second.second)
-      {
-        it->second.second = ! it->second.second;
-        if (it->second.second)
-          events.push_back(makeButtonEvent(it->first, pressed));
-        else
-          events.push_back(makeButtonEvent(it->first, released));
-      }
+void
+Controller::clear()
+{
+  events.clear ();
 }
 
 const Button*
 Controller::get_button (ButtonName name)
 {
   if (buttons.count(name))
-    return buttons[name].first;
+    return buttons[name];
 
   return 0;
 }
 
+void
+Controller::on_button_down(ButtonName name)
+{
+  events.push_back(makeButtonEvent(name, pressed));
+}
+
+void
+Controller::on_button_up(ButtonName name)
+{
+  events.push_back(makeButtonEvent(name, released));
+}
+
 } // namespace Input
 } // namespace Pingus
 

Modified: trunk/src/input/controller.hxx
===================================================================
--- trunk/src/input/controller.hxx      2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/input/controller.hxx      2004-06-23 22:13:52 UTC (rev 2338)
@@ -24,6 +24,7 @@
 #include <list>
 #include <string>
 #include <vector>
+#include <ClanLib/signals.h>
 #include "../libxmlfwd.hxx"
 
 #include "event.hxx"
@@ -42,13 +43,15 @@
   Pointer*  standard_pointer;
   Scroller* scroller;
 
-  std::map<ButtonName, std::pair<Button*, bool> > buttons;
+  std::map<ButtonName, Button*> buttons;
 
   std::vector<Event> events;
 
   float             std_pointer_x;
   float             std_pointer_y;
 
+  std::vector<CL_Slot> slots;
+
 public:
   Controller (const std::string& configfile);
   ~Controller ();
@@ -62,6 +65,7 @@
   const Button* get_button (ButtonName name);
 
   void update (float delta);
+  void clear();
 
   static void set_current(Controller* controller) { current_controller = 
controller; }
   static Controller* get_current() { return current_controller; }
@@ -69,6 +73,8 @@
 private:
   static Controller* current_controller;
 
+  void on_button_down(ButtonName name);
+  void on_button_up(ButtonName name);
   void create_action_buttons (xmlNodePtr cur);
 
   Controller (const Controller&);

Modified: trunk/src/input/event.hxx
===================================================================
--- trunk/src/input/event.hxx   2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/input/event.hxx   2004-06-23 22:13:52 UTC (rev 2338)
@@ -36,53 +36,43 @@
 
 struct ButtonEvent
 {
-  EventType  type;
   ButtonName name;
   State      state;
 };
 
-//#include "pointer_event.hxx"
-
 enum PointerName { standard };
 
 struct PointerEvent
 {
-  EventType type;
   PointerName  name;
   float x;
   float y;
-
 };
 
-
-//#include "axis_event.hxx"
 enum AxisName  { action };
 
 struct AxisEvent
 {
-  EventType type;
   float     dir;
   AxisName  name;
 };
 
-
-//#include "scroll_event.hxx"
-
 struct ScrollEvent
 {
-  EventType type;
   float x_delta;
   float y_delta;
 };
 
-union Event
+struct Event
 {
   EventType type;
 
-  ButtonEvent  button;
-  PointerEvent pointer;
-  AxisEvent    axis;
-  ScrollEvent  scroll;
+  union {
+    ButtonEvent  button;
+    PointerEvent pointer;
+    AxisEvent    axis;
+    ScrollEvent  scroll;
+  };
 };
 
 typedef std::vector<Event> EventLst;
@@ -91,7 +81,7 @@
 {
   Event event;
 
-  event.button.type  = ButtonEventType;
+  event.type  = ButtonEventType;
   event.button.name  = name;
   event.button.state = state;
 
@@ -102,7 +92,7 @@
 {
   Event event;
 
-  event.pointer.type = PointerEventType;
+  event.type = PointerEventType;
   event.pointer.name = name;
   event.pointer.x    = x;
   event.pointer.y    = y;
@@ -114,7 +104,7 @@
 {
   Event event;
 
-  event.axis.type = AxisEventType;
+  event.type = AxisEventType;
   event.axis.dir  = dir;
   event.axis.name = name;
 
@@ -125,7 +115,7 @@
 {
   Event event;
 
-  event.scroll.type    = ScrollEventType;
+  event.type    = ScrollEventType;
   event.scroll.x_delta = x_delta;
   event.scroll.y_delta = y_delta;
 

Modified: trunk/src/input/event_fwd.hxx
===================================================================
--- trunk/src/input/event_fwd.hxx       2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/input/event_fwd.hxx       2004-06-23 22:13:52 UTC (rev 2338)
@@ -27,7 +27,7 @@
 namespace Pingus {
 namespace Input {
 
-union Event;
+struct Event;
 typedef std::vector<Event> EventLst;
 
 } // namespace Input

Modified: trunk/src/plf.cxx
===================================================================
--- trunk/src/plf.cxx   2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/plf.cxx   2004-06-23 22:13:52 UTC (rev 2338)
@@ -41,7 +41,6 @@
 // Destroy all data
 PLF::~PLF()
 {
-  std::cout << "PLF::~PLF: Deleting std::vector<WorldObjData*>" << std::endl;
   for (std::vector<WorldObjData*>::iterator i = worldobjs_data.begin ();
        i != worldobjs_data.end (); ++i)
     {

Modified: trunk/src/state_sprite.cxx
===================================================================
--- trunk/src/state_sprite.cxx  2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/state_sprite.cxx  2004-06-23 22:13:52 UTC (rev 2338)
@@ -32,8 +32,15 @@
   sprites[state] = sprite;
 }
 
+void 
+StateSprite::update(float delta)
+{
+  for(Sprites::iterator i = sprites.begin(); i != sprites.end(); ++i)
+    (*i).second.update(delta);
+}
+
 CL_Sprite&
-StateSprite::operator()(int state)
+StateSprite::operator[](int state)
 {
   Sprites::iterator i = sprites.find(state);
   if (i != sprites.end())

Modified: trunk/src/state_sprite.hxx
===================================================================
--- trunk/src/state_sprite.hxx  2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/state_sprite.hxx  2004-06-23 22:13:52 UTC (rev 2338)
@@ -36,8 +36,9 @@
 public:
   StateSprite();
   
+  void update(float delta);
   void load(int state, CL_Sprite);
-  CL_Sprite& operator()(int state);
+  CL_Sprite& operator[](int state);
 };
 
 } // namespace Pingus

Modified: trunk/src/worldmap/pingus.cxx
===================================================================
--- trunk/src/worldmap/pingus.cxx       2004-06-17 01:12:12 UTC (rev 2337)
+++ trunk/src/worldmap/pingus.cxx       2004-06-23 22:13:52 UTC (rev 2338)
@@ -68,9 +68,9 @@
       float direction = get_direction();
       
       if (direction >= 0 && direction < 180)
-        gc.draw(sprite(Direction::RIGHT), pos);
+        gc.draw(sprite[Direction::RIGHT], pos);
       else
-        gc.draw(sprite(Direction::LEFT), pos);
+        gc.draw(sprite[Direction::LEFT], pos);
     }
 }
 
@@ -79,9 +79,9 @@
 {
   float direction = get_direction();
   if (direction >= 0 && direction < 180)
-    sprite(Direction::RIGHT).update(delta);
+    sprite[Direction::RIGHT].update(delta);
   else
-    sprite(Direction::LEFT).update(delta);
+    sprite[Direction::LEFT].update(delta);
   
   if (is_walking())
     update_walk(delta);

Modified: trunk/src/worldobjsdata/worldobj_group_data.cxx
===================================================================
--- trunk/src/worldobjsdata/worldobj_group_data.cxx     2004-06-17 01:12:12 UTC 
(rev 2337)
+++ trunk/src/worldobjsdata/worldobj_group_data.cxx     2004-06-23 22:13:52 UTC 
(rev 2338)
@@ -61,7 +61,6 @@
 
 WorldObjGroupData::~WorldObjGroupData ()
 {
-  std::cout << "WorldObjGroupData::~WorldObjGroupData ()" << std::endl;
   for (ObjsIter i = objs.begin (); i != objs.end (); ++i)
     delete *i;
 }





reply via email to

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