Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9783 was 9777, checked in by zifloria, 12 years ago

enemies

File size: 3.3 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    void InvaderShip::tick(float dt)
57    {
58        // if (camera == NULL)
59        //     camera = this->getCamera();
60        // if (camera != NULL)
61        //     camera->setPosition(Vector3(0, 0, 0) + this->getWorldPosition());
62
63        if (this->hasLocalController())
64        {
65            this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); //
66            //this->setVelocity(this->getOrientation() * Vector3(1, 0, 0));
67        }
68        lastTimeFront += dt * damping;
69        lastTimeLeft += dt * damping;
70        velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
71        velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
72
73        if (isFireing)
74            ControllableEntity::fire(0);
75
76        if (getPosition().x > 30000)
77        {
78            //level++
79            setPosition(getPosition() - Vector3(30000, 0, 0));
80        }
81
82        // if ((int(getPosition().x) % 1000) < 5)
83        // {
84        //     for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
85        //         it->spawnEnemy();
86        // }
87
88        // camera->setOrientation(Vector3::UNIT_X, Degree(0));
89
90
91        SUPER(InvaderShip, tick, dt);
92    }
93
94
95
96    void InvaderShip::moveFrontBack(const Vector2& value)
97    {
98        // orxout(internal_error) << "move backfront" << value.x << value.y << endl;
99        //velocity.y = value.y * speed * 10;
100        lastTimeFront = 0;
101        desiredVelocity.y = value.y * speed * 10;
102    }
103
104    void InvaderShip::moveRightLeft(const Vector2& value)
105    {
106        // orxout(internal_error) << "right left front" << value.x << value.y << endl;
107        lastTimeLeft = 0;
108        desiredVelocity.x = value.x * speed;
109        // velocity.x = value.x * speed;
110    }
111    void InvaderShip::boost(bool bBoost)
112    {
113        isFireing = bBoost;
114    }
115}
Note: See TracBrowser for help on using the repository browser.