Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/JumpShip.cc @ 10035

Last change on this file since 10035 was 10032, checked in by fvultier, 11 years ago

Neue Platformen werden zur Laufzeit hinzugefugt, wenn sich die Ansicht nach oben verschiebt. Eigene Modelle importieren funktioniert.

File size: 4.8 KB
RevLine 
[10005]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 JumpShip.cc
31    @brief Implementation of the JumpShip class.
32*/
33
34#include "JumpShip.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38#include "Jump.h"
39
40namespace orxonox
41{
42    RegisterClass(JumpShip);
43
44    JumpShip::JumpShip(Context* context) : SpaceShip(context)
45    {
46        RegisterObject(JumpShip);
47
48        //speed = 500;
49        //isFireing = false;
50        //damping = 10;
[10017]51        leftPressed = false;
52        rightPressed = false;
53        upPressed = false;
54        downPressed = false;
55        yVelocity = 0;
[10005]56    }
57
58    void JumpShip::tick(float dt)
59    {
[10032]60
61
[10017]62        Vector3 movement(0,0,0);
63        Vector3 shipPosition = getPosition();
[10005]64
[10017]65        // Berechne Bewegung anhand der Eingabe
66        if (leftPressed == true)
[10005]67        {
[10017]68                movement -= Vector3(xVelocity, 0, 0);
69                leftPressed = false;
[10005]70        }
[10017]71        else if (rightPressed == true)
[10005]72        {
[10017]73                movement += Vector3(xVelocity, 0, 0);
74                rightPressed = false;
[10005]75        }
76
[10017]77        if (upPressed == true)
78        {
79                //movement += Vector3(0, xVelocity, 0);
80                yVelocity = ySpeedAfterJump;
81                upPressed = false;
82        }
83        else if (downPressed == true)
84        {
85                movement -= Vector3(0, 0, 0);
86                downPressed = false;
87        }
[10005]88
[10017]89        movement += Vector3(0, yVelocity, 0);
90        yVelocity -= yAcceleration;
[10005]91
[10017]92        // Skalierung der Bewegung je nach vergangener Zeit
93        movement *= dt;
94
95        // Verschiebe das Schiff um den berechneten Vektor movement und verhindere Verlassen des Bildschrims
96        shipPosition.x = clamp(shipPosition.x + movement.x, -xBoundary, xBoundary);
97                shipPosition.y += movement.y;
98
99        setPosition(shipPosition);
100
[10032]101        SUPER(JumpShip, tick, dt);
[10005]102    }
103/*
104    void JumpShip::updateLevel()
105    {
106        lastTime = 0;
107        if (getGame())
108            getGame()->levelUp();
109    }*/
110
111    void JumpShip::moveFrontBack(const Vector2& value)
112    {
[10017]113        if (value.y < 0)
114        {
115                downPressed = true;
116        }
117        else if (value.y > 0)
118        {
119                upPressed = true;
120        }
[10005]121        //lastTimeLeft = 0;
122        //desiredVelocity.x = -value.x * speed;
123    }
124
125    void JumpShip::moveRightLeft(const Vector2& value)
126    {
[10017]127        if (value.x < 0)
[10005]128        {
[10017]129                leftPressed = true;
[10005]130        }
[10017]131        else if (value.x > 0)
[10005]132        {
[10017]133                rightPressed = true;
[10005]134        }
135        //lastTimeFront = 0;
136        //desiredVelocity.y = value.y * speed * 42;
137    }
138
139    /*
140    void JumpShip::boost(bool bBoost)
141    {
142        isFireing = bBoost;
143    }
144    inline bool JumpShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
145    {
146        // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
147        WeakPtr<JumpEnemy> enemy = orxonox_cast<JumpEnemy*>(otherObject);
148        WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject);
149        // ensure that this gets only called once per enemy.
150        if (enemy != NULL && lastEnemy != enemy)
151        {
152            lastEnemy = enemy;
153
154            removeHealth(20);
155            if (getGame())
156            {
157                getGame()->multiplier = 1;                   
158            }
159        }
160        // was shot, decrease multiplier
161        else if (shot != NULL  && lastShot != shot)
162        {
163            if (getGame() && orxonox_cast<JumpEnemy*>(shot->getShooter()) != NULL)
164            {
165                if (getGame()->multiplier > 1)
166                {
167                    lastShot = shot;
168                    getGame()->multiplier -= 1;     
169                }
170            }
171        }
172        return false;
173        // SUPER(JumpShip, collidesAgainst, otherObject, contactPoint);
174    }
175
176    void JumpShip::death()
177    {
178        getGame()->costLife();
179        SpaceShip::death();
180    }
181*/
182    WeakPtr<Jump> JumpShip::getGame()
183    {
184        if (game == NULL)
185        {
186            for (ObjectList<Jump>::iterator it = ObjectList<Jump>::begin(); it != ObjectList<Jump>::end(); ++it)
187            {
188                game = *it;
189            }
190        }
191        return game;
192    }
193
194}
Note: See TracBrowser for help on using the repository browser.