Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2008, 10:36:49 AM (16 years ago)
Author:
landauf
Message:

added something like an AI… or at least something thats pretty close to what we call AI. it's not that clever, sometimes it does some sign errors. but hey, I don't care, at least it makes the game look more living.

Location:
code/branches/network/src/orxonox
Files:
4 added
5 edited

Legend:

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

    r1406 r1479  
    2525  objects/NPC.cc
    2626  objects/Projectile.cc
     27  objects/RotatingProjectile.cc
    2728  objects/Skybox.cc
    2829  objects/SpaceShip.cc
     30  objects/SpaceShipAI.cc
    2931  objects/WorldEntity.cc
    3032
  • code/branches/network/src/orxonox/OrxonoxPrereqs.h

    r1414 r1479  
    7474  class Skybox;
    7575  class SpaceShip;
     76  class SpaceShipAI;
    7677  class WorldEntity;
    7778
  • code/branches/network/src/orxonox/objects/Projectile.h

    r1454 r1479  
    5050            void setColour(const ColourValue& colour);
    5151
     52            static float getSpeed()
     53                { return Projectile::speed_; }
     54
     55        protected:
     56            SpaceShip* owner_;
     57
    5258        private:
    53             SpaceShip* owner_;
    5459            BillboardSet billboard_;
    5560            static float speed_;
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r1454 r1479  
    4545#include "particle/ParticleInterface.h"
    4646#include "Projectile.h"
     47#include "RotatingProjectile.h"
    4748#include "core/XMLPort.h"
    4849#include "core/ConsoleCommand.h"
     
    7879
    7980    SpaceShip::SpaceShip() :
    80       teamNr_(0),
    81       health_(100),
    8281      //testvector_(0,0,0),
    8382      //bInvertYAxis_(false),
     
    112111      mouseY_(0.0f),
    113112      emitterRate_(0.0f),
    114       myShip_(false)
     113      myShip_(false),
     114      teamNr_(0),
     115      health_(100)
    115116    {
    116117        RegisterObject(SpaceShip);
     
    125126        initialOrth_ = Vector3(0.0, 0.0, 1.0);
    126127        currentOrth_ = initialOrth_;
     128
     129        this->camName_ = this->getName() + "CamNode";
    127130
    128131        this->setRotationAxis(1, 0, 0);
     
    209212        // END CREATING BLINKING LIGHTS
    210213
    211         // START of testing crosshair
    212         this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    213         this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    214 
    215         this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
    216         this->chNearNode_->setInheritScale(false);
    217         this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
    218         this->chFarNode_->setInheritScale(false);
    219 
    220         this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    221         this->chNearNode_->setScale(0.2, 0.2, 0.2);
    222 
    223         this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    224         this->chFarNode_->setScale(0.4, 0.4, 0.4);
     214        if (this->isExactlyA(Class(SpaceShip)))
     215        {
     216            // START of testing crosshair
     217            this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     218            this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     219
     220            this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
     221            this->chNearNode_->setInheritScale(false);
     222            this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
     223            this->chFarNode_->setInheritScale(false);
     224
     225            this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
     226            this->chNearNode_->setScale(0.2, 0.2, 0.2);
     227
     228            this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
     229            this->chFarNode_->setScale(0.4, 0.4, 0.4);
     230        }
    225231
    226232        createCamera();
     
    362368        {
    363369
    364             Projectile *p = new Projectile(this);
     370            Projectile *p;
     371            if (this->isExactlyA(Class(SpaceShip)))
     372                p = new RotatingProjectile(this);
     373            else
     374                p = new Projectile(this);
     375            p->setColour(this->getProjectileColour());
    365376            p->create();
    366377            if(p->classID==0)
     
    463474          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
    464475    }
     476
    465477    void SpaceShip::movePitch(float val)
    466     {
    467         SpaceShip* this_ = getLocalShip();
    468         val = -val * val * sgn(val) * this_->rotationAcceleration_;
    469         if (val > this_->maxRotation_)
    470             val = this_->maxRotation_;
    471         if (val < -this_->maxRotation_)
    472             val = -this_->maxRotation_;
    473         this_->mouseYRotation_ = Radian(val);
    474     }
    475 
     478    {   getLocalShip()->setMovePitch(val);   }
    476479    void SpaceShip::moveYaw(float val)
    477     {
    478         SpaceShip* this_ = getLocalShip();
    479         val = -val * val * sgn(val) * this_->rotationAcceleration_;
    480         if (val > this_->maxRotation_)
    481             val = this_->maxRotation_;
    482         if (val < -this_->maxRotation_)
    483             val = -this_->maxRotation_;
    484         this_->mouseXRotation_ = Radian(val);
    485     }
    486 
     480    {   getLocalShip()->setMoveYaw(val);   }
    487481    void SpaceShip::moveRoll(float val)
    488     {
    489         SpaceShip* this_ = getLocalShip();
    490         this_->momentum_ = Radian(-this_->rotationAccelerationRadian_ * val);
    491         //COUT(3) << "rotating val: " << val << " acceleration: " << this_->rotationAccelerationRadian_.valueDegrees() << std::endl;
    492     }
    493 
     482    {   getLocalShip()->setMoveRoll(val);   }
    494483    void SpaceShip::moveLongitudinal(float val)
    495     {
    496         SpaceShip* this_ = getLocalShip();
    497         this_->acceleration_.x = this_->translationAcceleration_ * val;
    498     }
    499 
     484    {   getLocalShip()->setMoveLongitudinal(val);   }
    500485    void SpaceShip::moveLateral(float val)
    501     {
    502         SpaceShip* this_ = getLocalShip();
    503         this_->acceleration_.y = -this_->translationAcceleration_ * val;
    504     }
    505 
     486    {   getLocalShip()->setMoveLateral(val);   }
    506487    void SpaceShip::fire()
    507     {
    508         SpaceShip* this_ = getLocalShip();
    509         this_->bLMousePressed_ = true;
     488    {   getLocalShip()->doFire();   }
     489
     490    void SpaceShip::setMovePitch(float val)
     491    {
     492        val = -val * val * sgn(val) * this->rotationAcceleration_;
     493        if (val > this->maxRotation_)
     494            val = this->maxRotation_;
     495        if (val < -this->maxRotation_)
     496            val = -this->maxRotation_;
     497        this->mouseYRotation_ = Radian(val);
     498    }
     499
     500    void SpaceShip::setMoveYaw(float val)
     501    {
     502        val = -val * val * sgn(val) * this->rotationAcceleration_;
     503        if (val > this->maxRotation_)
     504            val = this->maxRotation_;
     505        if (val < -this->maxRotation_)
     506            val = -this->maxRotation_;
     507        this->mouseXRotation_ = Radian(val);
     508    }
     509
     510    void SpaceShip::setMoveRoll(float val)
     511    {
     512        this->momentum_ = Radian(-this->rotationAccelerationRadian_ * val);
     513        //COUT(3) << "rotating val: " << val << " acceleration: " << this->rotationAccelerationRadian_.valueDegrees() << std::endl;
     514    }
     515
     516    void SpaceShip::setMoveLongitudinal(float val)
     517    {
     518        this->acceleration_.x = this->translationAcceleration_ * val;
     519    }
     520
     521    void SpaceShip::setMoveLateral(float val)
     522    {
     523        this->acceleration_.y = -this->translationAcceleration_ * val;
     524    }
     525
     526    void SpaceShip::doFire()
     527    {
     528        this->bLMousePressed_ = true;
    510529    }
    511530}
  • code/branches/network/src/orxonox/objects/SpaceShip.h

    r1454 r1479  
    7676            static void moveLateral(float value);
    7777            static void fire();
     78            void setMovePitch(float value);
     79            void setMoveYaw(float value);
     80            void setMoveRoll(float value);
     81            void setMoveLongitudinal(float value);
     82            void setMoveLateral(float value);
     83            void doFire();
    7884
    7985            float getMaxSpeed();
     
    8288            Camera* getCamera();
    8389
     90            int getTeamNr() const
     91                { return this->teamNr_; }
     92            int getHealth() const
     93                { return this->health_; }
     94
    8495            bool getMyShip(){return myShip_;}
    8596
    8697        protected:
    87             int teamNr_;
    88             int health_;
     98            void setTeamNr(int teamNr)
     99                { this->teamNr_ = teamNr; }
    89100
    90101        private:
    91102            void createCamera();
     103            virtual ColourValue getProjectileColour() const
     104                { return ColourValue(1.0, 1.0, 0.5); }
    92105
    93106            Vector3 testvector_;
     
    143156            bool myShip_;
    144157
     158            int teamNr_;
     159            int health_;
     160
    145161            static SpaceShip* instance_s;
    146162    };
Note: See TracChangeset for help on using the changeset viewer.