Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2019, 11:36:28 AM (5 years ago)
Author:
pomselj
Message:

Worked on Collision, doesn't work yet, compiles tho

File:
1 edited

Legend:

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

    r12344 r12346  
    5555    */
    5656    OrxoBloxBall::OrxoBloxBall(Context* context)
    57         : MovableEntity(context)
     57        : Pawn(context)
    5858    {
    5959        RegisterObject(OrxoBloxBall);
     
    6363        this->bDeleteBats_ = false;
    6464        this->relMercyOffset_ = 0.05f;
     65        this->orxoblox_ = this->getOrxoBlox();
    6566
    6667        this->registerVariables();
     
    206207        if (position != this->getPosition())
    207208            this->setPosition(position);
     209        this->Collides((this->orxoblox_->CheckForCollision(this)));
     210
     211 
    208212    }
    209213
     
    287291
    288292
    289     void OrxoBloxBall::Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
     293    void OrxoBloxBall::Bounce(OrxoBloxStones* otherObject) {
    290294
    291295        Vector3 velocity = this->getVelocity();
    292         Vector3 myPosition = otherObject->getPosition();
    293         btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
     296        Vector3 positionOtherObject = otherObject->getPosition();
     297        Vector3 myPosition = this->getPosition();
    294298        orxout() << "About to Bounce >D" << endl;
    295299        //if (positionOtherObject.y < 0) {
     
    298302        //else {
    299303       
    300             int distance_X = positionOtherObject.getX() - myPosition.x;
    301             int distance_Z = positionOtherObject.getZ() - myPosition.z;
     304            int distance_X = myPosition.x - positionOtherObject.x;
     305            int distance_Z = myPosition.z - positionOtherObject.z;
    302306
    303307            if (distance_X < 0)
     
    325329            }
    326330            this->setVelocity(velocity);
    327         //}
    328     }
    329 
    330 
    331     bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    332     {
     331    }
     332
     333
     334    void OrxoBloxBall::Collides(OrxoBloxStones* otherObject)
     335    {
     336
     337        if(otherObject == nullptr)
     338            return;
     339
    333340        orxout() << "About to Bounce >D" << endl;
    334         bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
    335         Bounce(otherObject, ownCollisionShape, contactPoint);
    336         return result;
     341        Bounce(otherObject);
     342    }
     343
     344    OrxoBlox* OrxoBloxBall::getOrxoBlox()
     345    {
     346        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
     347        {
     348            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
     349            return orxobloxGametype;
     350        }
     351        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
     352        return nullptr;
    337353    }
    338354
Note: See TracChangeset for help on using the changeset viewer.