Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/orxonox/objects/RotatingProjectile.cc @ 1479

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

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.

File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "OrxonoxStableHeaders.h"
29
30#include "core/CoreIncludes.h"
31#include "core/ConfigValueIncludes.h"
32#include <OgreBillboard.h>
33#include "RotatingProjectile.h"
34
35namespace orxonox
36{
37    CreateFactory(RotatingProjectile);
38
39    RotatingProjectile::RotatingProjectile(SpaceShip* owner) : Projectile(owner)
40    {
41        RegisterObject(RotatingProjectile);
42
43        this->time_ = 0;
44
45        if (this->owner_)
46        {
47            this->rotatingBillboard1_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
48            this->rotatingBillboard2_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
49
50            this->rotatingNode1_ = this->getNode()->createChildSceneNode(this->getName() + "rotating1", Vector3(0, 50, 0));
51            this->rotatingNode2_ = this->getNode()->createChildSceneNode(this->getName() + "rotating2", Vector3(0, -50, 0));
52            this->rotatingNode1_->attachObject(this->rotatingBillboard1_.getBillboardSet());
53            this->rotatingNode2_->attachObject(this->rotatingBillboard2_.getBillboardSet());
54            this->rotatingNode1_->scale(0.3, 0.3, 0.3);
55            this->rotatingNode2_->scale(0.3, 0.3, 0.3);
56        }
57
58        this->setConfigValues();
59    }
60
61    RotatingProjectile::~RotatingProjectile()
62    {
63    }
64
65    void RotatingProjectile::setConfigValues()
66    {
67        SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0));
68
69        this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
70        this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
71    }
72
73    void RotatingProjectile::tick(float dt)
74    {
75        this->time_ += dt;
76
77        this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20));
78        this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20));
79
80        Projectile::tick(dt);
81    }
82}
Note: See TracBrowser for help on using the repository browser.