[Orxonox-commit 1168] r5889 - code/branches/core5/src/modules/pong

landauf at orxonox.net landauf at orxonox.net
Tue Oct 6 04:57:53 CEST 2009


Author: landauf
Date: 2009-10-06 04:57:53 +0200 (Tue, 06 Oct 2009)
New Revision: 5889

Modified:
   code/branches/core5/src/modules/pong/Pong.cc
   code/branches/core5/src/modules/pong/PongBall.cc
Log:
Using named events in Pong. Also firing events in PongBall now.

Modified: code/branches/core5/src/modules/pong/Pong.cc
===================================================================
--- code/branches/core5/src/modules/pong/Pong.cc	2009-10-06 02:56:42 UTC (rev 5888)
+++ code/branches/core5/src/modules/pong/Pong.cc	2009-10-06 02:57:53 UTC (rev 5889)
@@ -29,6 +29,7 @@
 #include "Pong.h"
 
 #include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
 #include "core/Executor.h"
 #include "PongCenterpoint.h"
 #include "PongBall.h"
@@ -38,6 +39,9 @@
 
 namespace orxonox
 {
+    CreateEventName(PongCenterpoint, right);
+    CreateEventName(PongCenterpoint, left);
+    
     CreateUnloadableFactory(Pong);
 
     Pong::Pong(BaseObject* creator) : Deathmatch(creator)
@@ -154,8 +158,11 @@
 
         if (this->center_)
         {
-            this->center_->fireEvent();
-
+            if (player == this->getRightPlayer())
+                this->center_->fireEvent(EventName(PongCenterpoint, right));
+            else if (player == this->getLeftPlayer())
+                this->center_->fireEvent(EventName(PongCenterpoint, left));
+            
             if (player)
                 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
         }

Modified: code/branches/core5/src/modules/pong/PongBall.cc
===================================================================
--- code/branches/core5/src/modules/pong/PongBall.cc	2009-10-06 02:56:42 UTC (rev 5888)
+++ code/branches/core5/src/modules/pong/PongBall.cc	2009-10-06 02:57:53 UTC (rev 5889)
@@ -101,13 +101,14 @@
         if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
         {
             velocity.z = -velocity.z;
-            if (GameMode::playsSound())
-                this->sidesound_->play();
-
             if (position.z > this->fieldHeight_ / 2)
                 position.z = this->fieldHeight_ / 2;
             if (position.z < -this->fieldHeight_ / 2)
                 position.z = -this->fieldHeight_ / 2;
+
+            this->fireEvent();
+            if (GameMode::playsSound())
+                this->sidesound_->play();
         }
 
         if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
@@ -124,6 +125,8 @@
                         position.x = this->fieldWidth_ / 2;
                         velocity.x = -velocity.x;
                         velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+                        
+                        this->fireEvent();
                         if (GameMode::playsSound())
                             this->batsound_->play();
                     }
@@ -146,6 +149,8 @@
                         position.x = -this->fieldWidth_ / 2;
                         velocity.x = -velocity.x;
                         velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+
+                        this->fireEvent();
                         if (GameMode::playsSound())
                             this->batsound_->play();
                     }




More information about the Orxonox-commit mailing list