Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 7, 2009, 2:02:15 AM (15 years ago)
Author:
landauf
Message:

Enhanced Pong gametype: It's now possible to accelerate the ball in the y direction by giving him a spin with a moving bat. Bots also support the new feature. Have fun :)

File:
1 edited

Legend:

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

    r5892 r5898  
    4646
    4747        this->speed_ = 0;
     48        this->accelerationFactor_ = 1.0f;
    4849        this->bat_ = 0;
    4950        this->batID_ = new unsigned int[2];
     
    7677        Vector3 position = this->getPosition();
    7778        Vector3 velocity = this->getVelocity();
     79        Vector3 acceleration = this->getAcceleration();
    7880
    7981        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     
    102104                        velocity.x = -velocity.x;
    103105                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     106                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
    104107                       
    105108                        this->fireEvent();
     
    122125                        velocity.x = -velocity.x;
    123126                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     127                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
    124128
    125129                        this->fireEvent();
     
    137141        }
    138142
     143        if (acceleration != this->getAcceleration())
     144            this->setAcceleration(acceleration);
    139145        if (velocity != this->getVelocity())
    140146            this->setVelocity(velocity);
Note: See TracChangeset for help on using the changeset viewer.