Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 16, 2005, 10:38:04 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: cleanup WorldEntity and Player (or at least started cleaning up)

Location:
orxonox/branches/weaponSystem/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/world_entities/player.cc

    r4836 r4877  
    2323
    2424#include "weapon_manager.h"
    25 #include "weapon.h"
    2625#include "test_gun.h"
    2726#include "world.h"
    2827
    2928#include "list.h"
    30 #include "stdincl.h"
    3129
    3230#include "event_handler.h"
    3331
    34 #include "projectile.h"
    3532#include "event.h"
    3633
     
    4138
    4239/**
    43  *  creates a new Player
     40 * creates a new Player
    4441 * @param isFree if the player is free
    4542*/
    4643Player::Player()
    4744{
    48   /*
    49     this is the debug player - actualy we would have to make a new
    50      class derivated from Player for each player. for now, we just use
    51      the player.cc for debug also
    52   */
    5345  this->init();
    5446
     
    7567  delete this->weaponMan;
    7668}
    77 
    7869
    7970/**
     
    119110
    120111/**
    121  *
     112 * loads the Settings of a Player from an XML-element.
    122113 * @param root the XML-element to load the Player's properties from
    123114 */
     
    132123
    133124/**
    134  *  adds a weapon to the weapon list of player
     125 * adds a weapon to the weapon list of player
    135126 * @param weapon to add
    136127*/
     
    219210void Player::tick (float time)
    220211{
    221   //printf("%p\n", this);
    222   //this->getRelCoor().debug();
    223 
    224   /* link tick to weapon */
    225   //this->activeWeapon->tick(time);
    226   //this->activeWeaponL->tick(time); //FIX FIX DELETE REMOVE
    227   this->weaponMan->tick(time);
    228212  // player controlled movement
    229213  this->move(time);
     214
     215  this->weaponMan->tick(time);
    230216  // weapon system manipulation
    231   this->weapon();
     217  this->weaponAction();
    232218}
    233219
     
    266252 *  weapon manipulation by the player
    267253*/
    268 void Player::weapon()
     254void Player::weaponAction()
    269255{
    270256  if( this->bFire)
     
    277263      this->bWeaponChange = false;
    278264    }
    279 }
    280 
    281 
    282 /**
    283  *  The connection to the command node
    284  * @param cmd the Command unit from witch to map
    285 
    286    here the commands are mapped to the players movement/weaponary
    287 */
    288 void Player::command (Command* cmd)
    289 {
    290   PRINTF(3)("recieved command [%s]\n", cmd->cmd);
    291   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_UP)) this->bUp = !cmd->bUp;
    292   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_DOWN)) this->bDown = !cmd->bUp;
    293   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_LEFT)) this->bLeft = !cmd->bUp;
    294   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_RIGHT)) this->bRight = !cmd->bUp;
    295   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_FIRE)) this->bFire = !cmd->bUp;
    296   if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_NEXT_WEAPON)) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange;
    297265}
    298266
  • orxonox/branches/weaponSystem/src/world_entities/player.h

    r4836 r4877  
    11/*!
    2     \file player.h
    3   * Implements a basic controllable WorldEntity
     2 * @file player.h
     3 * Implements a basic controllable WorldEntity
    44 */
    55
     
    1515class WeaponManager;
    1616class Vector;
    17 class World;
    1817class Event;
    19 class Crosshair;
    2018
    2119//! Basic controllable WorldEntity
     20/**
     21  *  this is the debug player - actualy we would have to make a new
     22     class derivated from Player for each player. for now, we just use
     23     the player.cc for debug also
     24*/
    2225class Player : public WorldEntity, public PhysicsInterface, public EventListener
    2326{
     
    4346    virtual void draw();
    4447
    45     virtual void command(Command* cmd);
    46 
    4748    virtual void process(const Event &event);
    4849
     
    5051  private:
    5152    void move(float time);
    52     void weapon();
     53    void weaponAction();
    5354
    5455
    5556  private:
    56     bool bUp;              //!< up button pressed.
    57     bool bDown;            //!< down button pressed.
    58     bool bLeft;            //!< left button pressed.
    59     bool bRight;           //!< right button pressed.
    60     bool bAscend;          //!< ascend button pressed.
    61     bool bDescend;         //!< descend button presses.
    62     bool bFire;            //!< fire button pressed.
    63     bool bWeaponChange;    //!< weapon change button pressed
     57    bool                  bUp;                //!< up button pressed.
     58    bool                  bDown;              //!< down button pressed.
     59    bool                  bLeft;              //!< left button pressed.
     60    bool                  bRight;             //!< right button pressed.
     61    bool                  bAscend;            //!< ascend button pressed.
     62    bool                  bDescend;           //!< descend button presses.
     63    bool                  bFire;              //!< fire button pressed.
     64    bool                  bWeaponChange;      //!< weapon change button pressed
    6465
    65     tList<Weapon>* weapons;//!< a list of weapon
    66     Weapon* activeWeapon;  //!< the weapon that is currenty activated
    67     Weapon* activeWeaponL;  //temporary -- FIX THIS
    68     WeaponManager* weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
     66    WeaponManager*        weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
    6967
    70     World* myWorld;        //!< reference to the world object
    71 
    72     Vector* velocity;       //!< the velocity of the player.
    73     float travelSpeed;     //!< the current speed of the player (to make soft movement)
    74     float acceleration;    //!< the acceleration of the player.
    75 
    76     Crosshair*  crosshair; //!< the crosshair of the player
     68    Vector*               velocity;           //!< the velocity of the player.
     69    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
     70    float                 acceleration;       //!< the acceleration of the player.
    7771};
    7872
  • orxonox/branches/weaponSystem/src/world_entities/world_entity.cc

    r4836 r4877  
    3838    this->loadParams(root);
    3939
    40   this->bDraw = true;
     40  this->setVisibiliy(true);
    4141}
    4242
     
    111111*/
    112112
    113 
    114 /**
    115   *  process draw function
    116 */
    117 void WorldEntity::processDraw ()
    118 {
    119 
    120 }
    121 
    122 /**
    123  *  sets the drawable state of this entity.
    124  * @param bDraw TRUE if draweable, FALSE otherwise
    125 */
    126 void WorldEntity::setDrawable (bool bDraw)
    127 {
    128   this->bDraw = bDraw;
    129 }
    130 
    131 
    132113/**
    133114 *  this function is called, when two entities collide
     
    183164{
    184165}
    185 
    186166
    187167/**
     
    228208  glPopMatrix();
    229209}
    230 
    231 /**
    232  *  this handles incoming command messages
    233  * @param cmd: a pointer to the incoming Command structure
    234 
    235    Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
    236    to send commands from one WorldEntity to another.
    237 */
    238 void WorldEntity::command (Command* cmd)
    239 {
    240 }
  • orxonox/branches/weaponSystem/src/world_entities/world_entity.h

    r4836 r4877  
    2626class WorldEntity : public PNode
    2727{
    28   friend class World;
    29 
    3028 public:
    3129  WorldEntity(const TiXmlElement* root = NULL);
     
    3533  void loadModel(const char* fileName);
    3634
    37   //void setCollision (CollisionCluster* newhull);
    3835
    3936  //void addAbility(Ability* ability);
    4037  //void removeAbility(Ability* ability);
    41   void setDrawable (bool bDraw);
     38
     39  /** @param visibility if the Entity should be visible (been draw) */
     40  void setVisibiliy (bool visibility) { this->bVisible = visibility; };
     41  /** @returns true if the entity is visible, false otherwise */
     42  bool isVisible() const { return this->bVisible; };
    4243  void setCharacterAttributes(CharacterAttributes* charAttr);
    4344  CharacterAttributes* getCharacterAttributes();
     
    4849  virtual void hit (WorldEntity* weapon, Vector* loc);
    4950  virtual void collideWith (WorldEntity* entity);
    50   virtual void command (Command* cmd);
    5151
    5252  /** @returns the Count of Faces on this WorldEntity */
    5353  virtual unsigned int getFaceCount () const { if (this->model) return this->model->getFaceCount(); else return 0; };
    5454
    55   void processDraw ();
    5655  virtual void draw ();
    5756  void drawBVTree(int depth, int drawMode);
     
    5958
    6059 protected:
    61   Model* model;                       //!< The model that should be loaded for this entity.
    62   CharacterAttributes* charAttr;      //!< the character attributes of a world_entity
    63   BVTree*             obbTree;       //!< this is the obb tree reference needed for collision detection
     60  Model*                  model;            //!< The model that should be loaded for this entity.
     61  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     62  BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
    6463
    6564 private:
    66   bool bCollide;                      //!< If it should be considered for the collisiontest.
    67   bool bDraw;                         //!< If it should be visible.
    68 
    69 
    70 
    71   //CollisionCluster* collisioncluster; //!< The collision-Cluster of this entity.
     65  bool                    bCollide;         //!< If it should be considered for the collisiontest.
     66  bool                    bVisible;         //!< If it should be visible.
    7267};
    7368
Note: See TracChangeset for help on using the changeset viewer.