Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2017, 4:17:43 PM (6 years ago)
Author:
vyang
Message:

Asteroiden werden generiert und bewegen sich, HUD muss noch angepasst werden, Punkte und Health und Leben anzeigen. Raumschiff kann noch nicht schiessen, evtl auch Schutzfunktion → nachdem ein Leben verloren wurde 2s Immunitaet?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc

    r11616 r11637  
    4444    {
    4545        RegisterObject(Asteroids2DStone);
    46         this->size = 1;
     46        this->size = rand()%3+1;
    4747        this->width = 1043;
    4848        this->height = 646;
    4949        this->setPosition(randomPosition(this->width, this->height));
     50        this->setCollisionTypeStr("dynamic");
     51        this->setVelocity(randomVelocity(MAX_SPEED));
     52    }
     53
     54    Asteroids2DStone::Asteroids2DStone(Context* c, int sze, Vector3 pos) : Pawn(c)
     55    {
     56        RegisterObject(Asteroids2DStone);
     57        this->size = sze;
     58        this->width = 1043;
     59        this->height = 646;
     60        this->setPosition(pos);
     61        this->setCollisionTypeStr("dynamic");
    5062        this->setVelocity(randomVelocity(MAX_SPEED));
    5163    }
     
    7486        SUPER(Asteroids2DStone, tick, dt);
    7587        Vector3 pos = this->getPosition();
    76         if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2)
    77         {
    78             Quaternion orientation = this->getOrientation();
    79             orientation.w -= 180;
    80             this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w));
     88
     89        if(pos.x >= width/2){
     90            pos.x = -width/2;
     91        }else if(pos.x <= -width/2){
     92            pos.x = -width/2;
     93        }else if(pos.z >= height/2){
     94            pos.z = -height/2;
     95        }else if(pos.z <= -height/2){
     96            pos.z = -width/2;
    8197        }
    8298
     99        this->setPosition(pos);
     100
    83101    }
     102
     103    inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     104    {
     105        if(orxonox_cast<Asteroids2DShip*>(otherObject))
     106        {
     107            this->split();
     108        }
     109        return false;
     110    }
     111
     112    void Asteroids2DStone::split()
     113    {
     114        if(size == 1)
     115        {
     116            this->death();
     117
     118        }else if(size == 2){
     119            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
     120            newStone1->addTemplate("stone1");
     121            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
     122            newStone2->addTemplate("stone1");
     123        }else{
     124            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
     125            newStone1->addTemplate("stone1");
     126            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
     127            newStone2->addTemplate("stone1");
     128        }
     129    }
     130
     131
    84132
    85133
Note: See TracChangeset for help on using the changeset viewer.