Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5889 for code/branches/core5


Ignore:
Timestamp:
Oct 6, 2009, 4:57:53 AM (15 years ago)
Author:
landauf
Message:

Using named events in Pong. Also firing events in PongBall now.

Location:
code/branches/core5/src/modules/pong
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/pong/Pong.cc

    r5831 r5889  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/EventIncludes.h"
    3233#include "core/Executor.h"
    3334#include "PongCenterpoint.h"
     
    3940namespace orxonox
    4041{
     42    CreateEventName(PongCenterpoint, right);
     43    CreateEventName(PongCenterpoint, left);
     44   
    4145    CreateUnloadableFactory(Pong);
    4246
     
    155159        if (this->center_)
    156160        {
    157             this->center_->fireEvent();
    158 
     161            if (player == this->getRightPlayer())
     162                this->center_->fireEvent(EventName(PongCenterpoint, right));
     163            else if (player == this->getLeftPlayer())
     164                this->center_->fireEvent(EventName(PongCenterpoint, left));
     165           
    159166            if (player)
    160167                this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
  • code/branches/core5/src/modules/pong/PongBall.cc

    r5885 r5889  
    102102        {
    103103            velocity.z = -velocity.z;
    104             if (GameMode::playsSound())
    105                 this->sidesound_->play();
    106 
    107104            if (position.z > this->fieldHeight_ / 2)
    108105                position.z = this->fieldHeight_ / 2;
    109106            if (position.z < -this->fieldHeight_ / 2)
    110107                position.z = -this->fieldHeight_ / 2;
     108
     109            this->fireEvent();
     110            if (GameMode::playsSound())
     111                this->sidesound_->play();
    111112        }
    112113
     
    125126                        velocity.x = -velocity.x;
    126127                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     128                       
     129                        this->fireEvent();
    127130                        if (GameMode::playsSound())
    128131                            this->batsound_->play();
     
    147150                        velocity.x = -velocity.x;
    148151                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     152
     153                        this->fireEvent();
    149154                        if (GameMode::playsSound())
    150155                            this->batsound_->play();
Note: See TracChangeset for help on using the changeset viewer.