Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3585 in orxonox.OLD


Ignore:
Timestamp:
Mar 16, 2005, 11:59:51 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: player now implements weapon change and fire

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/util/list.h

    r3553 r3585  
    8686  T* enumerate();
    8787  T* nextElement();
     88  T* nextElement(T* toEntity);
    8889  T* toArray();
    8990  void debug();
     
    199200T* tList<T>::enumerate()
    200201{
    201   if(this->size == 0) return NULL;
     202  if(this->last == this->first) return NULL;
    202203  this->currentEl = this->first;
    203204  return this->currentEl->curr;
     
    208209T* tList<T>::nextElement()
    209210{
    210   if(this->size == 0) return NULL;
     211  if(this->last == this->first) return NULL;
    211212  this->currentEl = this->currentEl->next;
    212213  if(this->currentEl == NULL) return NULL;
     
    215216
    216217
     218/**
     219   \brief this returns the next element after toEntity or the first if toEntity is last
     220*/
     221template<class T>
     222T* tList<T>::nextElement(T* toEntity)
     223{
     224  if( this->last == this->first) return NULL;
     225  if( toEntity == NULL) return this->first->curr;
     226  if( toEntity == this->last->curr ) return this->first->curr;
     227  this->currentEl = this->first;
     228  while(this->currentEl->curr != toEntity && this->currentEl->next != NULL)
     229    {
     230      this->currentEl = this->currentEl->next;
     231    }
     232  if(this->currentEl == NULL) return NULL;
     233  return this->currentEl->next->curr;
     234}
     235
     236
    217237template<class T>
    218238T* tList<T>::toArray()
  • orxonox/trunk/src/world_entities/player.cc

    r3584 r3585  
    3333  this->model = new OBJModel("../data/models/reaplow.obj");
    3434  this->weapons = new tList<Weapon>();
     35  this->activeWeapon = NULL;
     36
     37  travelSpeed = 15.0;
     38  velocity = Vector();
     39  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     40  bFire = false;
     41  acceleration = 10.0;
    3542}
    3643
     
    4754    }
    4855  delete this->weapons;
     56 
     57  //delete this->velocity;
    4958}
    5059
     
    7584void Player::postSpawn ()
    7685{
    77   travelSpeed = 15.0;
    78   velocity = Vector();
    79   bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    80   bFire = false;
    81   acceleration = 10.0;
    8286  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    8387}
     
    182186  if(this->bFire)
    183187    {
    184 
     188      if(this->activeWeapon != NULL)
     189        this->activeWeapon->fire();
    185190    }
    186191  if(this->bWeaponChange)
    187192    {
    188 
     193      Weapon* w = this->weapons->enumerate();
     194      this->activeWeapon = this->weapons->nextElement(this->activeWeapon);
    189195    }
    190196}
     
    199205void Player::command (Command* cmd)
    200206{
    201   //printf("Player|recieved command [%s]\n", cmd->cmd);
     207  PRINTF(3)("recieved command [%s]\n", cmd->cmd);
    202208  if( !strcmp( cmd->cmd, "up")) this->bUp = !cmd->bUp;
    203209  else if( !strcmp( cmd->cmd, "down")) this->bDown = !cmd->bUp;
  • orxonox/trunk/src/world_entities/player.h

    r3584 r3585  
    4343  bool bDescend;         //!< descend button presses.
    4444  bool bFire;            //!< fire button pressed.
    45   bool bWeaponChange;     //!< weapon change button pressed
     45  bool bWeaponChange;    //!< weapon change button pressed
    4646
    4747  tList<Weapon>* weapons;//!< a list of weapon
     48  Weapon* activeWeapon;  //!< the weapon that is currenty activated
    4849
    4950  Vector velocity;       //!< the velocity of the player.
Note: See TracChangeset for help on using the changeset viewer.