Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc @ 1993

Last change on this file since 1993 was 1993, checked in by landauf, 16 years ago

added several new classes

File size: 3.0 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "Spectator.h"
30
31#include "core/CoreIncludes.h"
32#include "objects/worldentities/Model.h"
33
34namespace orxonox
35{
36    CreateFactory(Spectator);
37
38    Spectator::Spectator()
39    {
40        RegisterObject(Spectator);
41
42        this->speed_ = 100;
43        this->rotationSpeed_ = 3;
44
45        this->yaw_ = 0;
46        this->pitch_ = 0;
47        this->roll_ = 0;
48        this->setHudTemplate("spectatorhud");
49
50        this->setDestroyWhenPlayerLeft(true);
51
52        Model* temp = new Model;
53        temp->setMeshSource("assff.mesh");
54        this->attach(temp);
55    }
56
57    Spectator::~Spectator()
58    {
59    }
60
61    void Spectator::tick(float dt)
62    {
63        Vector3 velocity = this->getVelocity();
64        velocity.normalise();
65        this->setVelocity(velocity * this->speed_);
66
67        this->yaw(Radian(this->yaw_ * dt * this->rotationSpeed_));
68        this->pitch(Radian(this->pitch_ * dt * this->rotationSpeed_));
69        this->roll(Radian(this->roll_ * dt * this->rotationSpeed_));
70
71        this->yaw_ = this->pitch_ = this->roll_ = 0;
72
73        SUPER(Spectator, tick, dt);
74
75        this->setVelocity(Vector3::ZERO);
76    }
77
78    void Spectator::setPlayer(PlayerInfo* player)
79    {
80        ControllableEntity::setPlayer(player);
81
82        this->setObjectMode(network::direction::toclient);
83    }
84
85    void Spectator::moveFrontBack(float value)
86    {
87        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::FRONT);
88    }
89
90    void Spectator::moveRightLeft(float value)
91    {
92        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::RIGHT);
93    }
94
95    void Spectator::moveUpDown(float value)
96    {
97        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::UP);
98    }
99
100    void Spectator::rotateYaw(float value)
101    {
102        this->yaw_ = value;
103    }
104
105    void Spectator::rotatePitch(float value)
106    {
107        this->pitch_ = value;
108    }
109
110    void Spectator::rotateRoll(float value)
111    {
112        this->roll_ = value;
113    }
114
115    void Spectator::fire()
116    {
117    }
118}
Note: See TracBrowser for help on using the repository browser.