Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3575 in orxonox.OLD for orxonox/trunk/src/world_entities


Ignore:
Timestamp:
Mar 16, 2005, 4:24:09 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: weapon skeleton extended

Location:
orxonox/trunk/src/world_entities
Files:
2 edited

Legend:

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

    r3573 r3575  
    2222#include "vector.h"
    2323#include "objModel.h"
     24#include "projectile.h"
    2425
    2526using namespace std;
    2627
    2728
     29/**
     30   \brief standard constructor
    2831
     32   creates a new weapon
     33*/
    2934Weapon::Weapon () : WorldEntity()
    3035{
    31   this->model = new OBJModel("../data/models/fighter.obj");
     36  this->model = new OBJModel("");
    3237}
    3338
    3439
    35 
     40/**
     41   \brief standard deconstructor
     42*/
    3643Weapon::~Weapon ()
    3744{
     
    3946}
    4047
    41 void Weapon::tick (float time) {}
    4248
    43 void Weapon::hit (WorldEntity* weapon, Vector loc) {}
     49/**
     50   \brief sets a new projectile to the weapon
     51   \param new projectile for this weapon
    4452
    45 void Weapon::destroy () {}
     53   weapon an projectile are independent, so you can combine them as you want
     54*/
     55void Weapon::setProjectile(Projectile* projectile)
     56{
     57  this->projectile = projectile;
     58}
    4659
    47 void Weapon::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {}
    4860
     61/**
     62   \brief sets a new projectile to the weapon
     63   \returns the current projectile of this weapon
     64
     65   weapon an projectile are independent, so you can combine them as you want
     66*/
     67Projectile* Weapon::getProjectile()
     68{
     69  return this->projectile;
     70}
     71
     72
     73/**
     74   \brief this activates the weapon
     75
     76   This is needed, since there can be more than one weapon on a ship. the
     77   activation can be connected with an animation. for example the weapon is
     78   been armed out.
     79*/
     80void Weapon::activate()
     81{}
     82
     83
     84/**
     85   \brief this deactivates the weapon
     86
     87   This is needed, since there can be more than one weapon on a ship. the
     88   activation can be connected with an animation. for example the weapon is
     89   been armed out.
     90*/
     91void Weapon::deactivate()
     92{}
     93
     94/**
     95   \brief asks if the current weapon is active
     96   \returns true if it the weapon is active
     97*/
     98bool Weapon::isActive()
     99{}
     100
     101
     102
     103
     104
     105/**
     106   \brief tick signal for time dependent/driven stuff
     107*/
     108void Weapon::tick (float time)
     109{}
     110
     111/**
     112   \brief is called, when the weapon gets hit (=collide with something)
     113   \param from which entity it is been hit
     114   \param where it is been hit
     115
     116   this may not be used, since it would make the game relay complicated when one
     117   can destroy the weapons of enemies or vice versa.
     118*/
     119void Weapon::hit (WorldEntity* entity, Vector position)
     120{}
     121
     122/**
     123   \brief is called, when the weapon is destroyed
     124
     125   this is in conjunction with the hit function, so when a weapon is able to get
     126   hit, it can also be destoryed.
     127*/
     128void Weapon::destroy ()
     129{}
     130
     131
     132/**
     133   \brief this will draw the weapon
     134*/
    49135void Weapon::draw ()
    50136{
    51137  glMatrixMode(GL_MODELVIEW);
    52138  glPushMatrix();
     139
    53140  float matrix[4][4];
    54  
    55141  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    56   //rotate
    57142  this->getAbsDir().matrix (matrix);
    58143  glMultMatrixf((float*)matrix);
    59  
    60144  this->model->draw();
    61145
  • orxonox/trunk/src/world_entities/weapon.h

    r3573 r3575  
    1616    weapon in this world:
    1717     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
     18     o shooting animation
    1819     
    1920*/
     
    2526#include "world_entity.h"
    2627
     28class Projectile;
    2729
    2830class Weapon : public WorldEntity
     
    3436  virtual ~Weapon ();
    3537 
    36   virtual void tick (float time);
     38  void setProjectile(Projectile* projectile);
     39  Projectile* getProjectile();
     40
     41  void activate();
     42  void deactivate();
     43  bool isActive();
     44
     45  void setWeaponEnergy(int energy);
     46  void addWeaponEnergy(int addEnergy);
     47  void substractWeaponEnergy(int subEnergy);
     48  int getWeaponEnergy();
     49
     50  void fire();
    3751  virtual void hit (WorldEntity* weapon, Vector loc);
    3852  virtual void destroy ();
    39   virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
     53 
     54  virtual void tick (float time);
    4055  virtual void draw ();
     56
    4157
    4258 private:
    4359  float firingRate;
     60  float localTime;
    4461  float slowDownFactor;
    4562  int energyConsumption;
     63  Projectile* projectile;
    4664
    4765};
Note: See TracChangeset for help on using the changeset viewer.