Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10032 in orxonox.OLD for branches/playability/src


Ignore:
Timestamp:
Dec 6, 2006, 7:07:24 PM (18 years ago)
Author:
muellmic
Message:

changed roll- handling at left/right translation

Location:
branches/playability/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/story_entities/game_world.cc

    r9869 r10032  
    346346      this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
    347347  {
    348     PRINTF(4)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
     348    PRINTF(0)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
    349349  }
    350350  else
    351351  {
    352     PRINTF(2)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
     352    PRINTF(0)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
    353353  }
    354354}
  • branches/playability/src/world_entities/playable.cc

    r9869 r10032  
    4444
    4545Playable::Playable()
    46     : weaponMan(this),
    47     supportedPlaymodes(Playable::Full3D),
     46    : weaponMan(this)
     47    ,supportedPlaymodes(Playable::Full3D),
    4848    playmode(Playable::Full3D)
    4949{
  • branches/playability/src/world_entities/playable.h

    r9961 r10032  
    7171  void setCameraMode(unsigned int cameraMode = 0);
    7272  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
    73   bool setPlaymode(Playable::Playmode playmode);
     73  virtual bool setPlaymode(Playable::Playmode playmode);
    7474  Playable::Playmode getPlaymode() const { return this->playmode; };
    7575  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10030 r10032  
    133133  srand(time(0));   //initialize Random Nomber Generator
    134134
    135   this->setSupportedPlaymodes(Playable::Vertical);
    136 
    137135  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    138136  this->registerObject(this, SpaceShip::_objectList);
     
    386384
    387385  this->travelNode->debugDraw();
     386
     387  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
    388388}
    389389
     
    396396{
    397397  Playable::loadParams(root);
    398 }
     398
     399  LoadParam(root, "playmode", this, SpaceShip, setPlaymodeXML);
     400}
     401
    399402
    400403void SpaceShip::setPlayDirection(const Quaternion& rot, float speed)
    401404{
    402   this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
     405  //this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
    403406}
    404407
     
    446449  this->secWeaponMan.showCrosshair();
    447450  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    448   if (!this->setPlaymode(Playable::Vertical))
    449     std::cout << "playmode not supported";
    450451  //this->attachCamera();
     452 // this->setPlaymode(Playable::Horizontal);
    451453}
    452454
     
    791793      //break;
    792794
    793 
    794     case Playable::Vertical:
     795      break;
     796    case Playable::Horizontal:
    795797      if (State::getCameraNode != NULL)
    796798      {
     
    805807
    806808        State::getCameraNode()->setParentSoft(this->travelNode);
    807         State::getCameraNode()->setRelCoorSoft(-0.01, 40,0);
     809        State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
    808810        State::getCameraTargetNode()->setParentSoft(this->travelNode);
    809811        State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     
    817819      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
    818820  }
    819   std::cout << Playable::playmodeToString(this->getPlaymode());
    820821}
    821822
     
    833834  float pi = 3.14;
    834835
    835   // these routines will change the travel movement into zero in a short amout of time, if the player
    836   // doesn't press any buttons.
    837   if (this->velocity.x >= 0)
    838   {
    839     if (this->velocity.x > airCoeff*this->acceleration * dt)
    840       this->velocity.x -= airCoeff* this->acceleration * dt;
    841     else
    842       this->velocity.x = 0;
    843   }
    844   else
    845   {
    846     if (this->velocity.x < -airCoeff*this->acceleration * dt)
    847       this->velocity.x += airCoeff* this->acceleration * dt;
    848     else
    849       this->velocity.x = 0;
    850   }
    851   if (this->velocity.z >= 0)
    852   {
    853     if (this->velocity.z > airCoeff*this->acceleration * dt)
    854       this->velocity.z -= airCoeff* this->acceleration * dt;
    855     else
    856       this->velocity.z = 0;
    857   }
    858   else
    859   {
    860     if (this->velocity.z < -airCoeff*this->acceleration * dt)
    861       this->velocity.z += airCoeff* this->acceleration * dt;
    862     else
    863       this->velocity.z = 0;
    864   }
    865 
    866   // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons
    867   // and its continuing to slide a bit.
    868   Vector oldCoor = this->getRelCoor();
    869   if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z);
    870   if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z);
    871   if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y);
    872   if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y);
    873 
    874   if( this->systemFailure() )
    875     bForward = bBackward = bLeft = bRight = false;
    876 
    877 
    878   if( this->bForward )
    879   {
    880     if(this->getRelCoor().x < this->travelDistancePlus.x)
     836 
     837
     838  switch(this->getPlaymode())
     839  {
     840    case Playable::Horizontal:
    881841    {
    882       if (this->velocity.x < this->travelSpeed)
    883       {
    884         this->velocity.x += (airCoeff + 1.0)*this->acceleration*dt;
     842      // these routines will change the travel movement into zero in a short amout of time, if the player
     843      // doesn't press any buttons.
     844      if (this->velocity.x >= 0)
     845      {
     846        if (this->velocity.x > airCoeff*this->acceleration * dt)
     847          this->velocity.x -= airCoeff* this->acceleration * dt;
     848        else
     849          this->velocity.x = 0;
    885850      }
    886851      else
    887852      {
    888         this->velocity.x = this->travelSpeed;
    889       }
     853        if (this->velocity.x < -airCoeff*this->acceleration * dt)
     854          this->velocity.x += airCoeff* this->acceleration * dt;
     855        else
     856          this->velocity.x = 0;
     857      }
     858      if (this->velocity.z >= 0)
     859      {
     860        if (this->velocity.z > airCoeff*this->acceleration * dt)
     861          this->velocity.z -= airCoeff* this->acceleration * dt;
     862        else
     863          this->velocity.z = 0;
     864      }
     865      else
     866      {
     867        if (this->velocity.z < -airCoeff*this->acceleration * dt)
     868          this->velocity.z += airCoeff* this->acceleration * dt;
     869        else
     870          this->velocity.z = 0;
     871      }
     872   
     873      // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons
     874      // and its continuing to slide a bit.
     875      Vector oldCoor = this->getRelCoor();
     876      if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z);
     877      if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z);
     878      if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y);
     879      if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y);
     880   
     881      if( this->systemFailure() )
     882        bForward = bBackward = bLeft = bRight = false;
     883   
     884   
     885      if( this->bForward )
     886      {
     887        if(this->getRelCoor().x < this->travelDistancePlus.x)
     888        {
     889          if (this->velocity.x < this->travelSpeed)
     890          {
     891            this->velocity.x += (airCoeff + 1.0)*this->acceleration*dt;
     892          }
     893          else
     894          {
     895            this->velocity.x = this->travelSpeed;
     896          }
     897        }
     898        else
     899        {
     900          this->velocity.x = 0.0f;
     901        }
     902      }
     903   
     904      if( this->bBackward )
     905      {
     906        if(this->getRelCoor().x > this->travelDistanceMinus.x)
     907        {
     908          if (this->velocity.x > -this->travelSpeed)
     909          {
     910            this->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
     911          }
     912          else
     913          {
     914            this->velocity.x = -this->travelSpeed;
     915          }
     916        }
     917        else
     918        {
     919          this->velocity.x = 0.0f;
     920        }
     921      }
     922   
     923      if( this->bLeft)
     924      {
     925        if(this->getRelCoor().z > this->travelDistanceMinus.y)
     926        {
     927          if (this->velocity.z > -this->travelSpeed)
     928          {
     929            this->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
     930          }
     931          else
     932          {
     933            this->velocity.z = -this->travelSpeed;
     934          }
     935        }
     936        else
     937        {
     938          this->velocity.z = 0.0f;
     939        }
     940        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 3);
     941      }
     942   
     943      if( this->bRight)
     944      {
     945        if(this->getRelCoor().z < this->travelDistancePlus.y)
     946        {
     947          if (this->velocity.z < this->travelSpeed)
     948          {
     949            this->velocity.z += (airCoeff + 1.0)*this->acceleration*dt;
     950          }
     951          else
     952          {
     953            this->velocity.z = this->travelSpeed;
     954          }
     955        }
     956        else
     957        {
     958          this->velocity.z = 0.0f;
     959        }
     960        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 3);
     961      }
     962      if (!this->bRight && !this->bLeft)
     963      {
     964        this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 3);
     965      }
     966
     967      this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
     968      this->shiftCoor (this->velocity * dt);
     969
     970
     971      break;
    890972    }
    891     else
     973    case Playable::Vertical:
    892974    {
    893       this->velocity.x = 0.0f;
     975      break;
    894976    }
    895   }
    896 
    897   if( this->bBackward )
    898   {
    899     if(this->getRelCoor().x > this->travelDistanceMinus.x)
    900     {
    901       if (this->velocity.x > -this->travelSpeed)
    902       {
    903         this->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
    904       }
    905       else
    906       {
    907         this->velocity.x = -this->travelSpeed;
    908       }
    909     }
    910     else
    911     {
    912       this->velocity.x = 0.0f;
    913     }
    914   }
    915 
    916   if( this->bLeft)
    917   {
    918     if(this->getRelCoor().z > this->travelDistanceMinus.y)
    919     {
    920       if (this->velocity.z > -this->travelSpeed)
    921       {
    922         this->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
    923       }
    924       else
    925       {
    926         this->velocity.z = -this->travelSpeed;
    927       }
    928     }
    929     else
    930     {
    931       this->velocity.z = 0.0f;
    932     }
    933   }
    934 
    935   if( this->bRight)
    936   {
    937     if(this->getRelCoor().z < this->travelDistancePlus.y)
    938     {
    939       if (this->velocity.z < this->travelSpeed)
    940       {
    941         this->velocity.z += (airCoeff + 1.0)*this->acceleration*dt;
    942       }
    943       else
    944       {
    945         this->velocity.z = this->travelSpeed;
    946       }
    947     }
    948     else
    949     {
    950       this->velocity.z = 0.0f;
    951     }
    952   }
    953  
    954   this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    955   this->shiftCoor (this->velocity * dt);
    956  
    957   float angle = this->velocity.z / travelSpeed * pi / 3;
    958   if (angle > pi/3) angle = pi/3;
    959   if (angle < -pi/3) angle = -pi/3;
    960   this->setRelDirSoft(Quaternion(angle, Vector(1,0,0)), 5.0f);
    961 
    962   /*
    963   switch(this->getPlaymode())
    964   {
    965     case Playable::Vertical:
    966       break;
    967977    default:
    968       PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
    969   }
    970   */
    971 }
    972 
     978      PRINTF(4)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
     979  }
     980}
     981
     982void SpaceShip::setPlaymodeXML(const std::string& playmode)
     983{
     984  this->setPlaymode(Playable::stringToPlaymode(playmode));
     985}
     986
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r10030 r10032  
    7272
    7373    virtual void enterPlaymode(Playable::Playmode playmode);
     74    void setPlaymodeXML(const std::string& playmode);
    7475    virtual void movement (float dt);
    7576
     
    7778    void init();
    7879
    79     void calculateVelocity(float time);
     80    //void calculateVelocity(float time);
    8081
    8182    void regen(float time);  //!< handler for shield and electronic regeneration
     
    131132    bool                  bAscend;            //!< ascend button pressed.
    132133    bool                  bDescend;           //!< descend button presses.
    133 //    bool                  bFire;              //!< fire button pressed.(moved to playable)
    134134    bool                  bRollL;             //!< rolling button pressed (left)
    135135    bool                  bRollR;             //!< rolling button pressed (right)
     
    144144    int                   controlVelocityY;
    145145    */
    146 //   float                 cycle;              //!< hovercycle
    147146
    148 
    149     Vector                velocity;           //!< the velocity of the player.
    150     //Vector                oldVelocity;        //!< the velocity the player had last synced
    151 
    152 
     147Vector                velocity;           //!< the velocity of the player.
    153148
    154149// 2D-traveling
     
    173168    */
    174169
    175     Quaternion            direction;          //!< the direction of the ship.
     170    //Quaternion            direction;          //!< the direction of the ship.
    176171    float                 acceleration;       //!< the acceleration of the ship.
    177172    //float                 airFriction;        //!< AirFriction.
Note: See TracChangeset for help on using the changeset viewer.