Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12360 for code


Ignore:
Timestamp:
May 9, 2019, 3:32:40 PM (5 years ago)
Author:
pomselj
Message:

bounces moore smoothly

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

Legend:

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

    r12359 r12360  
    242242            this->stones_.push_back(this->futureWall_->getStone(i));
    243243        }
     244
     245        for(OrxoBloxWall* wall : this->activeWalls_) {
     246            if(wall->isEmpty()) {
     247                wall->destroy();
     248            }
     249            int NumberOfStones = 0;
     250            for(int i = 0; i < 10; i++) {
     251                if(wall->getStone(i) == nullptr) {
     252                    continue;
     253                }
     254                else {
     255                    NumberOfStones++;
     256                }
     257
     258            }
     259        }
    244260        //new location of ship
    245261        //new amount of balls
     
    283299            orxout() << "Checking a stone" << endl;
    284300            const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
    285             int size = someStone->getSize();
    286             if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) &&
    287                 (BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) {
     301            int size = someStone->getSize()/2;
     302            if((BallPosition.x - Ball->getRadius() >= StonePosition.x - size && BallPosition.x + Ball->getRadius() <= StonePosition.x + size) &&
     303                (BallPosition.z - Ball->getRadius() >= StonePosition.z - size && BallPosition.z + Ball->getRadius() <= StonePosition.z + size)) {
    288304                orxout() << "FOUND ONE" << endl;
    289305                return someStone;
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12356 r12360  
    6767        this->relMercyOffset_ = 0.05f;
    6868        this->orxoblox_ = this->getOrxoBlox();
     69        this->radius_ = 1.5;
    6970
    7071        this->registerVariables();
     
    302303        Vector3 myPosition = this->getPosition();
    303304        orxout() << "About to Bounce >D" << endl;
    304         //if (positionOtherObject.y < 0) {
    305             //this.destroy()
    306         //}S
    307         //else {
    308305       
    309306            int distance_X = myPosition.x - positionStone.x;
     
    322319            if (distance_X < distance_Z) {
    323320                velocity.z = -velocity.z;
    324                 orxout() << "z" << endl;
     321                orxout() << "z" << endl; 
    325322            }
    326             if (distance_Z < distance_X) {
     323            else if (distance_Z < distance_X) {
    327324                velocity.x = -velocity.x;
    328                 orxout() << "x" << endl;
     325                orxout() << "x" << endl;       
    329326            }
    330327            else {
     
    332329                velocity.z = -velocity.z;
    333330                orxout() << "both" << endl;
    334             }
     331            }                                 
     332
    335333            this->setVelocity(velocity);
     334            this->setPosition(myPosition);
    336335    }
    337336
     
    346345        Bounce(Stone);
    347346        //if(otherObject->getHealth() <= 0) {
    348             Stone->destroy();
     347        Stone->destroy();
     348
    349349        //}
    350350        //otherObject->reduceHealth();
     
    362362    }
    363363
     364    float OrxoBloxBall::getRadius() {
     365        return this->radius_;
     366    }
     367
    364368
    365369}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h

    r12356 r12360  
    134134            void setDefBoundarySound(const std::string& engineSound);
    135135            const std::string& getDefBoundarySound();
     136            float getRadius();
    136137
    137             unsigned int getHealth();
    138138
    139139        private:
     
    141141
    142142            OrxoBlox* getOrxoBlox();
     143            float radius_;
    143144            float fieldWidth_; //!< The width of the playing field.
    144145            float fieldHeight_; //!< The height of the playing field.
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc

    r12356 r12360  
    2929        this->health_ -= 1;
    3030    }
     31
     32    float OrxoBloxStones::getSize() {
     33        return this->size_;
     34    }
    3135}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h

    r12356 r12360  
    6767
    6868            void reduceHealth();
     69
     70            float getSize();
    6971               
    7072        private:
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc

    r12350 r12360  
    9898        return num_Stones_;
    9999    }
     100
     101    void OrxoBloxWall::setNumberOfStones(int number) {
     102        this->num_Stones_ = number;
     103    }
     104
     105    bool OrxoBloxWall::isEmpty() {
     106        if (num_Stones_ == 0) {
     107            return true;
     108        }
     109        return false;
     110    }
     111
     112    void OrxoBloxWall::reduceNumberOfStones() {
     113        if(num_Stones_ == 0) {
     114            orxout() << "Wanted to reduce number of stones, but there were none" << endl;
     115        }
     116        this->num_Stones_ -= 1;
     117    }
    100118}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h

    r12346 r12360  
    4343                { assert(orxoblox); orxoblox_ = orxoblox; }
    4444            int getNumberOfStones();
     45            bool isEmpty();
     46            void reduceNumberOfStones();
     47            void setNumberOfStones(int number);
    4548        private:
    4649            void createWall(void);
Note: See TracChangeset for help on using the changeset viewer.