Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2007, 2:41:01 AM (17 years ago)
Author:
landauf
Message:

added a simple firing mode to SpaceShip

Location:
code/branches/FICN/src/orxonox/objects
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/objects/CMakeLists.txt

    r638 r643  
    2020  BillboardSet.cc
    2121  Light.cc
     22  Projectile.cc
    2223  weapon_system/ammunition_dump.cc
    2324  weapon_system/barrel_gun.cc
  • code/branches/FICN/src/orxonox/objects/SpaceShip.cc

    r633 r643  
    2727
    2828#include "SpaceShip.h"
     29#include "Projectile.h"
    2930
    3031#include "../../tinyxml/tinyxml.h"
     
    4546
    4647        SetConfigValue(bInvertMouse_, true);
     48        SetConfigValue(reloadTime_, 0.1);
    4749
    4850        this->setMouseEventCallback_ = false;
     51        this->bMousePressed_ = false;
    4952
    5053        this->tt_ = 0;
     
    5255        this->greenNode_ = 0;
    5356        this->blinkTime_ = 0;
     57
     58        this->timeToReload_ = 0;
    5459
    5560        this->moveForward_ = 0;
     
    201206    }
    202207
     208    bool SpaceShip::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
     209    {
     210        this->bMousePressed_ = true;
     211
     212        return true;
     213    }
     214
     215    bool SpaceShip::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
     216    {
     217        this->bMousePressed_ = false;
     218    }
     219
    203220    void SpaceShip::tick(float dt)
    204221    {
     
    221238            this->redNode_->setScale(redScale, redScale, redScale);
    222239            this->greenNode_->setScale(greenScale, greenScale, greenScale);
     240        }
     241
     242        if (this->timeToReload_ > 0)
     243            this->timeToReload_ -= dt;
     244        else
     245            this->timeToReload_ = 0;
     246
     247        if (this->bMousePressed_ && this->timeToReload_ <= 0)
     248        {
     249            Projectile* proj = new Projectile(this);
     250            this->timeToReload_ = this->reloadTime_;
    223251        }
    224252
  • code/branches/FICN/src/orxonox/objects/SpaceShip.h

    r633 r643  
    3636            void maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft);
    3737            bool mouseMoved(const OIS::MouseEvent &e);
    38             bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    39             bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
     38            bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
     39            bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
    4040
    4141
     
    4343            bool bInvertMouse_;
    4444            bool setMouseEventCallback_;
     45            bool bMousePressed_;
    4546
    4647            particle::ParticleInterface *tt_;
     
    5152            Ogre::SceneNode* greenNode_;
    5253            float blinkTime_;
     54
     55            float timeToReload_;
     56            float reloadTime_;
    5357
    5458            float moveForward_;
  • code/branches/FICN/src/orxonox/objects/WorldEntity.cc

    r637 r643  
    7575        {
    7676            this->velocity_ += (dt * this->acceleration_);
    77             this->translate(dt * this->velocity_);
     77            this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
    7878
    7979            this->rotationRate_ += (dt * this->momentum_);
     
    151151
    152152        create();
    153        
     153
    154154    }
    155155
     
    158158      return true;
    159159    }
    160    
     160
    161161    void WorldEntity::registerAllVariables()
    162162    {
  • code/branches/FICN/src/orxonox/objects/WorldEntity.h

    r637 r643  
    2323      virtual void loadParams(TiXmlElement* xmlElem);
    2424      bool create();
    25      
     25
    2626      inline Ogre::SceneNode* getNode()
    2727          { return this->node_; }
     
    5353          { this->node_->roll(angle, relativeTo); }
    5454
     55      inline const Ogre::Quaternion& getOrientation()
     56        { return this->node_->getOrientation(); }
     57      inline void setOrientation(const Ogre::Quaternion& quat)
     58        { this->node_->setOrientation(quat); }
    5559      inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
    5660        { this->node_->rotate(axis, angle, relativeTo); }
     
    5963      inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
    6064        { this->node_->setDirection(vec, relativeTo, localDirectionVector); }
    61       inline void setOrientation(const Ogre::Quaternion quat)
    62         { this->node_->setOrientation(quat); }
    6365      inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
    6466        { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); }
     
    122124      inline const Radian& getMomentum() const
    123125          { return this->momentum_; }
    124       inline const Ogre::Quaternion& getOrientation()
    125           { return this->node_->getOrientation(); }
    126126
    127127      inline void setStatic(bool bStatic)
Note: See TracChangeset for help on using the changeset viewer.