Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/invaders/src/modules/invader/InvaderShip.cc @ 9744

Last change on this file since 9744 was 9744, checked in by zifloria, 10 years ago

Added everything I modified and a few funky things

File size: 2.9 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 *      Florian Zinggeler
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file InvaderShip.cc
31    @brief Implementation of the InvaderShip class.
32*/
33
34#include "InvaderShip.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38
39namespace orxonox
40{
41    RegisterClass(InvaderShip);
42
43    /**
44    @brief
45        Constructor. Registers and initializes the object.
46    */
47    InvaderShip::InvaderShip(Context* context) : SpaceShip(context)
48    {
49        RegisterObject(InvaderShip);
50
51        speed = 500;
52        isFireing = false;
53        damping = 10;
54
55    }
56
57    void InvaderShip::tick(float dt)
58    {
59        // if (camera == NULL)
60        //     camera = this->getCamera();
61        // if (camera != NULL)
62        //     camera->setPosition(Vector3(0, 0, 0) + this->getWorldPosition());
63
64        if (this->hasLocalController())
65        {
66            this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); //
67            //this->setVelocity(this->getOrientation() * Vector3(1, 0, 0));
68        }
69        lastTimeFront += dt * damping;
70        lastTimeLeft += dt * damping;
71        velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
72        velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
73
74        if (isFireing)
75            ControllableEntity::fire(0);
76
77
78        // camera->setOrientation(Vector3::UNIT_X, Degree(0));
79
80
81        SUPER(InvaderShip, tick, dt);
82    }
83
84    void InvaderShip::moveFrontBack(const Vector2& value)
85    {
86        // orxout(internal_error) << "move backfront" << value.x << value.y << endl;
87        //velocity.y = value.y * speed * 10;
88        lastTimeFront = 0;
89        desiredVelocity.y = value.y * speed * 10;
90    }
91
92    void InvaderShip::moveRightLeft(const Vector2& value)
93    {
94        // orxout(internal_error) << "right left front" << value.x << value.y << endl;
95        lastTimeLeft = 0;
96        desiredVelocity.x = value.x * speed;
97        // velocity.x = value.x * speed;
98    }
99    void InvaderShip::boost(bool bBoost)
100    {
101        isFireing = bBoost;
102    }
103}
Note: See TracBrowser for help on using the repository browser.