Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3172 in orxonox.OLD for orxonox/branches/dave/src/player.cc


Ignore:
Timestamp:
Dec 14, 2004, 11:36:07 PM (21 years ago)
Author:
bensch
Message:

orxonox/branches/dave: (commit from dave) now the fighter banks while moving. really cool stuff

File:
1 edited

Legend:

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

    r3155 r3172  
    2929  obj = new Object ("reaplow.obj");
    3030  tottime=0.0f;
     31  movfinishright=movfinishleft=movfinishup=movfinishdown=false;
     32  angleturn=false;
    3133 
    3234  /*
     
    9395{
    9496  //printf("Player|recieved command [%s]\n", cmd->cmd);
     97 
    9598  tottime=cmd->tottime;
     99  rottime=cmd->rottime;
     100  angleturn=cmd->angleturn;
     101 
     102 
    96103  if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
    97104  else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
     
    106113  glLoadIdentity();
    107114  float matrix[4][4];
    108  
     115  float a[3];
     116  a[0]=.8f;
     117  a[1]=.8f;
     118  a[2]=.8f;
     119  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    109120  glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
    110121  get_placement()->w.matrix (matrix);
    111122  glMultMatrixf ((float*)matrix);
    112   
     123 
    113124  glMatrixMode (GL_MODELVIEW);
     125  glRotatef (angle,0,0,1);
    114126  glRotatef (-90, 0,1,0);
     127 
    115128  obj->draw();
    116129  //  glCallList (objectList);
     
    141154  Vector orthDirection(0.0, 0.0, 1.0);
    142155  orthDirection = orthDirection.cross(direction);
     156 
     157  if(rottime<1.0f)
     158          rottime=rottime+2.5f*time;
     159  else
     160          rottime=1.0f;
    143161  if(tottime<1.5f)
    144162          tottime=tottime+4.0f*time;
    145163  else
    146164          tottime=1.5f;
    147   if( bUp) { accel = accel+(direction*acceleration*pow(tottime,2.0f)); }
    148   if( bDown) { accel = accel-(direction*acceleration*pow(tottime,2.0f)); }
    149   if( bLeft ) { accel = accel + (orthDirection*acceleration*pow(tottime,2.0f)); }
    150   if( bRight ) { accel = accel - (orthDirection*acceleration*pow(tottime,2.0f));}
     165 
     166  //Langsam zurückdrehen    ->anlgeturn ist für das Zurückdrehen verantwortlich!
     167  if((angleturn||bLeft&&bRight)&&angle<=0.0f){
     168          if(!bLeft)
     169          angle=angle+rottime*10.0f;
     170          if(angle>0.0f){
     171                 
     172                  angleturn=false;
     173                  angle=0.0f;}
     174          }
     175 
     176  if((angleturn||bLeft&&bRight)&&angle>=0.0f){
     177          if(!bRight)
     178          angle=angle-rottime*10.0f;
     179          if(angle<0.0f){
     180                  angleturn=false;
     181                  angle=0.0f;}
     182                }
     183  //Bewegung lansam abbremsen    **************
     184  if(movfinishleft&&!bLeft){
     185          accel=accel+(orthDirection*acceleration*(tottimecopy-pow(tottime,1.5f)+.5f));
     186          if(tottime>tottimecopy)
     187                  movfinishleft=false;
     188  }
     189  if(movfinishright&&!bRight){
     190        accel=accel-(orthDirection*acceleration*(tottimecopy-pow(tottime,1.5f)+.5f));
     191        if(tottime>tottimecopy)
     192                movfinishright=false;
     193  }
     194  if(movfinishup&&!bUp){
     195        accel=accel+(direction*acceleration*(tottimecopy-pow(tottime,1.5f)+.5f));
     196        if(tottime>tottimecopy)
     197                movfinishup=false;
     198  }
     199 
     200  if(movfinishdown&&!bDown){
     201        accel=accel-(direction*acceleration*(tottimecopy-pow(tottime,1.5f)+.5f));
     202        if(tottime>tottimecopy)
     203                movfinishdown=false;
     204  } 
     205  //                            **************
     206 
     207  if( bUp) { accel = accel+(direction*acceleration*pow(tottime,2.0f));movfinishup=true;tottimecopy=tottime;}
     208  if( bDown) { accel = accel-(direction*acceleration*pow(tottime,2.0f));movfinishdown=true;tottimecopy=tottime; }
     209  if( bLeft ) { accel = accel + (orthDirection*acceleration*pow(tottime,2.0f));
     210        if(angle>-40.0f){
     211          angle=angle-rottime*40.0f;}
     212        movfinishleft=true;
     213        tottimecopy=tottime;}
     214  if( bRight ) { accel = accel - (orthDirection*acceleration*pow(tottime,2.0f));
     215        if(angle<40.0f){
     216          angle=angle+rottime*40.0f;}
     217          movfinishright=true;
     218          tottimecopy=tottime;
     219  }
    151220  if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
    152221  if( bDescend) {/* FIXME */}
Note: See TracChangeset for help on using the changeset viewer.