Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4780 in orxonox.OLD for orxonox/trunk/src/world_entities/player.cc


Ignore:
Timestamp:
Jul 2, 2005, 10:55:47 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: 1. the crosshair is registered, @patrick: i thought it was a little bit harder… worked myself through the EventSystem, it is quite cool :)

  1. Player now knows a loadParams and init routine

also testing the Crosshair inside of the Player

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/player.cc

    r4762 r4780  
    3333#include "event.h"
    3434
     35#include "crosshair.h"
     36
    3537using namespace std;
    3638
     
    4850     the player.cc for debug also
    4951  */
     52  this->init();
     53
     54  //weapons:
     55  this->weaponMan = new WeaponManager();
     56  Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
     57  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
     58
     59  this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
     60  this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
     61  this->weaponMan->addWeapon(wpRight, W_CONFIG2);
     62  this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     63
     64}
     65
     66
     67/**
     68   \brief destructs the player, deletes alocated memory
     69*/
     70Player::~Player ()
     71{
     72  /* do not delete the weapons, they are contained in the pnode tree
     73     and will be deleted there.
     74     this only frees the memory allocated to save the list.
     75  */
     76  delete this->weaponMan;
     77}
     78
     79
     80/**
     81   \brief creates a new Player from Xml Data
     82   \param root the xml element containing player data
     83
     84   \todo add more parameters to load
     85*/
     86Player::Player(const TiXmlElement* root)
     87{
     88  this->init();
     89  this->loadParams(root);
     90
     91  //weapons:
     92  this->weaponMan = new WeaponManager();
     93  Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
     94  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
     95
     96  this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
     97  this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
     98  this->weaponMan->addWeapon(wpRight, W_CONFIG2);
     99  this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     100
     101
     102  new Crosshair();
     103}
     104
     105/**
     106 * initializes a Player
     107 */
     108void Player::init()
     109{
    50110  this->setClassID(CL_PLAYER, "Player");
    51111
     
    57117  this->bWeaponChange = false;
    58118  acceleration = 10.0;
    59   //weapons:
    60   this->weaponMan = new WeaponManager();
    61   Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
    62   Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    63 
    64   this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    65   this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
    66   this->weaponMan->addWeapon(wpRight, W_CONFIG2);
    67   this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
    68 }
    69 
    70 
    71 /**
    72    \brief destructs the player, deletes alocated memory
    73 */
    74 Player::~Player ()
    75 {
    76   /* do not delete the weapons, they are contained in the pnode tree
    77      and will be deleted there.
    78      this only frees the memory allocated to save the list.
    79   */
    80   delete this->weaponMan;
    81 }
    82 
    83 
    84 /**
    85    \brief creates a new Player from Xml Data
    86    \param root the xml element containing player data
    87 
    88    \todo add more parameters to load
    89 */
    90 Player::Player(const TiXmlElement* root) : WorldEntity(root)
    91 {
    92   this->setClassID(CL_PLAYER, "Player");
    93 
    94   this->weapons = new tList<Weapon>();
    95   this->activeWeapon = NULL;
    96   /*
    97     this is the debug player - actualy we would have to make a new
    98      class derivated from Player for each player. for now, we just use
    99      the player.cc for debug also
    100   */
    101   travelSpeed = 15.0;
    102   velocity = new Vector();
    103   bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    104   bFire = false;
    105   this->bWeaponChange = false;
    106   acceleration = 10.0;
    107   //weapons:
    108   this->weaponMan = new WeaponManager();
    109   Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
    110   Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    111 
    112   this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    113   this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
    114   this->weaponMan->addWeapon(wpRight, W_CONFIG2);
    115   this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     119}
     120
     121
     122/**
     123 *
     124 * @param root the XML-element to load the Player's properties from
     125 */
     126void Player::loadParams(const TiXmlElement* root)
     127{
     128  static_cast<WorldEntity*>(this)->loadParams(root);
     129
     130
     131
    116132}
    117133
Note: See TracChangeset for help on using the changeset viewer.