Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2019, 11:14:44 AM (5 years ago)
Author:
jeromela
Message:

Working on setting new speed

Location:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12343 r12344  
    138138            this->center_->attach(this->ball_);
    139139            //Startposition Ball
    140             this->ball_->setPosition(0, 0, 50);
     140            this->ball_->setPosition(0, 0, 40);
    141141            this->ball_->setFieldDimension(this->center_->getFieldDimension());
    142142            this->ball_->setSpeed(0);
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12340 r12344  
    4343#include "sound/WorldSound.h"
    4444#include "core/XMLPort.h"
    45 
    46 #include "OrxoBloxStones.h"
    4745
    4846namespace orxonox
     
    149147                position.z = this-> fieldHeight_ / 2;
    150148                // Set the velocity to zero
    151                 this->setSpeed(0); // doesn't work here, why??;
    152                 //velocity.x = 0;
    153                 //velocity.y = 0;
    154                 //velocity.z = 0;
    155                 orxout() << "Output" << endl;
    156                 ChatManager::message("Waiting");
     149
     150                //this->setSpeed(0); // doesn't work here, why??;
     151                //Stopping ball
     152                orxout() << "Ball stopped" << endl;
     153                velocity.x = 0;
     154                velocity.y = 0;
     155                velocity.z = 0;
     156
     157                ChatManager::message("Waiting for your input");
     158                //Input new speed here:
     159                ChatManager::message("Setting new speed");
     160
     161                //Set new speed here!!
     162                velocity.x = rnd(-100,100);
     163                velocity.z = rnd(-10,-100);
     164               
     165               
     166
    157167            }
    158168            if (position.z < -this->fieldHeight_ / 2){
     
    205215    */
    206216    void OrxoBloxBall::setSpeed(float speed)
    207     {
     217    {   
     218
    208219        if (speed != this->speed_) // If the speed changes
    209220        {
    210221            this->speed_ = speed;
    211 
    212222            // Set the speed in the direction of the balls current velocity.
    213223            Vector3 velocity = this->getVelocity();
    214             //if (velocity.x != 0)
    215                 velocity.x = sgn(velocity.x) * this->speed_;
    216             //else // If the balls current velocity is zero, the speed is set in a random direction.
    217             //    velocity.x = this->speed_ * sgn(rnd(-1,1));
     224            if (velocity.x != 0)
     225                velocity.x = speed;
     226                //velocity.x = sgn(velocity.x) * speed;
     227            else // If the balls current velocity is zero, the speed is set in a random direction.
     228                velocity.x = speed * sgn(rnd(-1,1));
    218229            //velocity.y = this->speed_;
    219             velocity.z = this->speed_;
     230            velocity.z = speed;
    220231
    221232            this->setVelocity(velocity);
     
    279290
    280291        Vector3 velocity = this->getVelocity();
    281         Vector3 positionOtherObject = otherObject->getPosition();
    282         btVector3 myPosition = contactPoint.getPositionWorldOnA();
     292        Vector3 myPosition = otherObject->getPosition();
     293        btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
    283294        orxout() << "About to Bounce >D" << endl;
     295        //if (positionOtherObject.y < 0) {
     296            //this.destroy()
     297        //}S
     298        //else {
    284299       
    285             int distance_X = myPosition.getX() - positionOtherObject.x;
    286             int distance_Z = myPosition.getZ() - positionOtherObject.z;
     300            int distance_X = positionOtherObject.getX() - myPosition.x;
     301            int distance_Z = positionOtherObject.getZ() - myPosition.z;
    287302
    288303            if (distance_X < 0)
     
    319334        bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
    320335        Bounce(otherObject, ownCollisionShape, contactPoint);
    321         OrxoBloxStones* stone = orxonox_cast<OrxoBloxStones*>(otherObject);       
    322         if(stone != nullptr)
    323         {
    324             delete stone;
    325         }
    326336        return result;
    327337    }
Note: See TracChangeset for help on using the changeset viewer.