Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3698 in orxonox.OLD for orxonox/branches/shadows/src/player.cc


Ignore:
Timestamp:
Mar 31, 2005, 9:04:45 PM (19 years ago)
Author:
dave
Message:

branches/shadows: so jetzt ist die Ausgangslage geschaffen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/shadows/src/player.cc

    r3396 r3698  
    6666  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    6767  bFire = false;
    68   acceleration = 10.0;
     68  acceleration = 20.0;
    6969  setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    7070}
     
    103103  glLoadIdentity();
    104104  float matrix[4][4];
    105  
     105  //glRotatef(90.0f,1.0f,0.0f,0.0f);
    106106  /* translate */
    107107  glTranslatef (this->getAbsCoor ().x,
     
    111111  this->getAbsDir ().matrix (matrix);
    112112  glMultMatrixf((float*)matrix);
    113  
     113  glRotatef(angle,1.0f,0.0f,0.0f);
    114114  glMatrixMode(GL_MODELVIEW);
    115115  this->model->draw();
     
    132132void Player::move (float time)
    133133{
     134 
    134135  Vector accel(0.0, 0.0, 0.0);
     136 
    135137  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    136138  //Placement *pos = getPlacement();
     
    138140  /* calculate the direction in which the craft is heading  */
    139141  Vector direction (1.0, 0.0, 0.0);
     142   
     143 
     144 
    140145  //direction = this->absDirection.apply (direction);
    141146  Vector orthDirection (0.0, 0.0, 1.0);
     147 
    142148  //orthDirection = orthDirection.cross (direction);
    143149
    144   if( bUp) { accel = accel+(direction*acceleration); }
    145   if( bDown) { accel = accel-(direction*acceleration); }
    146   if( bLeft ) { accel = accel - (orthDirection*acceleration); }
    147   if( bRight ) { accel = accel + (orthDirection*acceleration); }
     150  if( bUp) { accel = accel+(direction*acceleration);accelSlipDirection=accel; }
     151  if( bDown) { accel = accel-(direction*acceleration);accelSlipDirection=accel; }
     152  if( bLeft ) {if(angle<0) {accel = accel-(orthDirection*acceleration);}rotate(time);accelSlip=accel; }
     153  if( bRight ) { if(angle>0){accel = accel+(orthDirection*acceleration);}rotate(time);accelSlip=accel;}
    148154  if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
    149155  if( bDescend) {/* FIXME */} /* \todo up and down player movement */
     156  if((int)angle!=0&&!bLeft&&!bRight){backRotate(time);accelSlip=accelSlip-slip(time,accelSlip);}
     157  if(!bUp&&!bDown){accelSlipDirection=accelSlipDirection-slip(time,accelSlipDirection);}
    150158
    151159  //Location* l = getLocation();
     
    159167  //l->dist = l->dist + travelSpeed * time;
    160168 
    161   Vector* shift = new Vector (this->travelSpeed * time, 0, 0);
    162   this->shiftCoor (shift);
     169  //Vector* shift = new Vector (this->travelSpeed * time, 0, 0);
     170  Vector shift(this->travelSpeed*time,0,0);
     171 
     172  this->shiftCoor (&shift);
    163173 
    164174  /* this updates the player position on the track - user interaction */
    165175  //l->pos = l->pos + accel*time;
     176 
    166177  Vector move = accel * time;
    167178  this->shiftCoor (&move);
    168 }
     179 
     180}
     181void Player::rotate(float time){
     182    if(bLeft&&angle>-40.0f){
     183        angle=angle-time*200.0f;
     184               
     185    }
     186    if(bRight&&angle<40.0f){
     187        angle=angle+time*200.0f;
     188               
     189    }
     190}
     191
     192void Player::backRotate(float time){
     193    if(angle<0){
     194    angle=angle+3.0f*(exp(angle*.0015f*time));
     195   
     196   
     197    }
     198    if(angle>0){
     199    angle=angle-3.0f*(exp(-angle*.0015f*time));
     200   
     201   
     202    }
     203
     204}
     205//When the sidewords movement is finished, the ship will still slip untill it stands still
     206Vector Player::slip(float time,Vector accel){
     207        Vector move= accel*time;
     208        this->shiftCoor(&move);
     209        return accel*time*3.0f;
     210   
     211}
     212
     213
     214
     215
     216
Note: See TracChangeset for help on using the changeset viewer.