Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc @ 10021

Last change on this file since 10021 was 10018, checked in by muemart, 11 years ago

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

File size: 1.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Martin Mueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29 #include "TurretController.h"
30
31 namespace orxonox
32 {
33        RegisterClass(TurretController);
34
35        TurretController::TurretController(Context* context) : ArtificialController(context)
36        {
37                RegisterObject(TurretController);
38                counter = 0;
39                flag = false;
40        }
41
42        TurretController::~TurretController()
43        {
44
45        }
46
47        void TurretController::tick(float dt)
48        {
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                }
66        }
67 }
Note: See TracBrowser for help on using the repository browser.