Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2019, 4:57:28 PM (5 years ago)
Author:
jeromela
Message:

Zielvisier eingefuegt

File:
1 edited

Legend:

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

    r12370 r12391  
    6969    void OrxoBloxShip::tick(float dt)
    7070    {
    71         SUPER(OrxoBloxShip, tick, dt);
    7271        Vector3 pos = this->getPosition();
     72
     73        //ensure that the ship stays in playing field
     74        if(pos.x > width/2)   pos.x = -width/2;
     75        if(pos.x < -width/2)  pos.x = width/2;
     76        if(pos.z > height/2)  pos.z = -height/2;
     77        if(pos.z < -height/2) pos.z = height/2;
     78
     79        //2D movement, position should always = 0 on y-axis
     80        if(pos.y!=0) pos.y = 0;
    7381        this->setPosition(pos);
     82
     83
     84        //if you hit an asteroid, the ship will turn -> you need to reorientate the ship
     85        Quaternion ort = this->getOrientation();
     86        ort.x = 0;
     87        ort.z = 0;
     88        this->setOrientation(ort);
    7489    }   
    7590
Note: See TracChangeset for help on using the changeset viewer.