Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 3, 2014, 2:57:05 PM (11 years ago)
Author:
muemart
Message:

Turret: Limit turret's rotation (not really precise though) & implement xml stuff

Location:
code/branches/turretFS14/src/modules/objects/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc

    r10008 r10018  
    3636        {
    3737                RegisterObject(TurretController);
     38                counter = 0;
     39                flag = false;
    3840        }
    3941
     
    4547        void TurretController::tick(float dt)
    4648        {
    47                 this->getControllableEntity()->rotateYaw(10*dt);
     49                counter += dt;
     50                if(counter >= 10)
     51                {
     52                        counter = 0;
     53                        flag = !flag;
     54                        orxout() << "Direction change" << endl;
     55                }
     56                if(flag)
     57                {
     58                        this->getControllableEntity()->rotatePitch(10*dt);
     59                        //this->getControllableEntity()->rotateYaw(10*dt);
     60                }
     61                else
     62                {
     63                        this->getControllableEntity()->rotatePitch(-10*dt);
     64                        //this->getControllableEntity()->rotateYaw(-10*dt);
     65                }
    4866        }
    4967 }
  • code/branches/turretFS14/src/modules/objects/controllers/TurretController.h

    r10008 r10018  
    4242
    4343                        virtual void tick(float dt);
     44
     45                private:
     46                        float counter;
     47                        bool flag;
    4448        };
    4549 }
Note: See TracChangeset for help on using the changeset viewer.