Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 7, 2007, 12:39:30 AM (18 years ago)
Author:
rgrieder
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto_vs05/src/orxonox_ship.cc

    r169 r177  
    3333
    3434#include "bullet.h"
     35#include "bullet_manager.h"
    3536
    3637#include "orxonox_ship.h"
     
    6263  * @param mNode The scene node which the ship will be attached to later.
    6364  */
    64   OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node)
     65  OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node,
     66        BulletManager *bulletManager)
    6567              : sceneMgr_(sceneMgr), rootNode_(node), currentSpeed_(Vector3(0, 0, 0)),
    6668        baseThrust_(1000), currentThrust_(Vector3::ZERO),
    67         objectCounter_(0), bulletSpeed_(400)
     69        objectCounter_(0), bulletManager_(bulletManager)//, bulletSpeed_(400)
    6870  {
    6971  }
     
    7678  OrxonoxShip::~OrxonoxShip()
    7779  {
     80    if (mainWeapon_)
     81      delete mainWeapon_;
    7882  }
    7983
     
    101105
    102106    // initialise weapon(s)
    103     SceneNode *mainWeaponNode = rootNode_->createChildSceneNode("mainWeaponNode");
    104     mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode, 1);
     107    SceneNode *mainWeaponNode = rootNode_
     108          ->createChildSceneNode("mainWeaponNode");
     109    mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode,
     110          bulletManager_, 1);
     111    mainWeapon_->addWeapon("Barrel Gun");
    105112
    106113          return true;
     
    110117  /**
    111118  * Gets the ship to accelerate in the current direction.
    112   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     119  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    113120  * @param value Acceleration between 0 and 1
    114121  */
    115122  void OrxonoxShip::setMainThrust(const Real value)
    116123  {
    117           //currentThrust_ = value * baseThrust_;
    118124    currentThrust_.z = value * baseThrust_;
    119125  }
     
    122128  /**
    123129  * Gets the ship to accelerate sideways regarding the current direction.
    124   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     130  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    125131  * @param value Acceleration between 0 and 1
    126132  */
    127133  void OrxonoxShip::setSideThrust(const Real value)
    128134  {
    129           //currentSideThrust_ = value * baseThrust_;
    130135    currentThrust_.x = value * baseThrust_;
    131136  }
     
    134139  /**
    135140  * Gets the ship to accelerate up and down.
    136   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     141  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    137142  * @param value Acceleration between 0 and 1
    138143  */
    139144  void OrxonoxShip::setYThrust(const Real value)
    140145  {
    141     //currentYThrust_ = value * baseThrust_;
    142146    currentThrust_.y = value * baseThrust_;
    143147  }
     
    189193  * @return Bullet containing speed and entity.
    190194  */
    191   Bullet* OrxonoxShip::fire()
     195  void OrxonoxShip::fire()
    192196  {
    193197          // TODO: Names must be unique!
    194           SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode(
     198          /*SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode(
    195199          "BulletNode" + StringConverter::toString(objectCounter_));
    196200          temp->setOrientation(rootNode_->getOrientation());
     
    201205          + StringConverter::toString(objectCounter_++), "Barrel.mesh"), currentSpeed_
    202206          + (rootNode_->getOrientation() * Vector3(0, 0, -1)).normalisedCopy()
    203           * bulletSpeed_);
     207          * bulletSpeed_);*/
     208
     209    mainWeapon_->primaryFireRequest();
    204210  }
    205211
     
    214220  bool OrxonoxShip::tick(unsigned long time, Real deltaTime)
    215221  {
     222    mainWeapon_->tick(time, deltaTime);
     223
    216224    Quaternion quad = rootNode_->getOrientation();
    217225    quad.normalise();
    218226    currentSpeed_ += quad * (Vector3(-1, -1, -1) * currentThrust_) * deltaTime;
    219     //currentSpeed_ += quad * Vector3(0, 0, -1) * currentThrust_ * deltaTime;
    220           //currentSpeed_ += quad * Vector3(-1, 0,  0) * currentSideThrust_ * deltaTime;
    221227
    222228          rootNode_->translate(currentSpeed_ * deltaTime);
Note: See TracChangeset for help on using the changeset viewer.