Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tgidronFS16/src/modules/hover/HoverShip.cc @ 11703

Last change on this file since 11703 was 11171, checked in by tgidron, 9 years ago

Pickups work; Lives Counter and Total Flag Counter

  • Property svn:eol-style set to native
File size: 3.7 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 *      Cyrill Burgener
24 *
25 */
26
27/**
28    @file HoverShip.cc
29    @brief Implementation of the HoverShip control
30*/
31
32#include "HoverShip.h"
33#include "core/CoreIncludes.h"
34#include "core/XMLPort.h"
35#include "Hover.h"
36//#include "NewHumanController.h"
37
38#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
39
40namespace orxonox
41{
42    RegisterClass(HoverShip);
43
44    HoverShip::HoverShip(Context* context) : SpaceShip(context)
45    {
46        RegisterObject(HoverShip);
47        enableCollisionCallback();
48        isFloor_ = false;
49        jumpBoost_ = 0;
50    }
51
52    void HoverShip::moveFrontBack(const Vector2& value)
53        { this->steering_.z -= value.x; }
54
55    void HoverShip::moveRightLeft(const Vector2& value)
56        { this->steering_.x += value.x; }
57
58    void HoverShip::moveUpDown(const Vector2& value)
59        { this->steering_.y += value.x; }
60
61    void HoverShip::rotateYaw(const Vector2& value)
62    {
63        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
64
65        Pawn::rotateYaw(value);
66    }
67
68    void HoverShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
69    {
70        SUPER(HoverShip, XMLPort, xmlelement, mode);
71
72        XMLPortParam(HoverShip, "jumpBoost", setJumpBoost, getJumpBoost, xmlelement, mode);
73    }
74
75    /**
76    @brief
77        Removed, does nothing.
78    @param value
79    */
80    void HoverShip::rotatePitch(const Vector2& value) { }
81
82    /**
83    @brief
84        Removed, does nothing.
85    @param value
86    */
87    void HoverShip::rotateRoll(const Vector2& value) { }
88
89    /**
90    @brief
91        Checks if the ship is touching the floor. The ship can only jump if there is contact with someting beneath it.
92    */
93    bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
94    {
95        SpaceShip::collidesAgainst(otherObject, cs, contactPoint);
96        //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint);
97
98        if (contactPoint.m_normalWorldOnB.y() > 0.6
99            && this->getVelocity().y < 1) {
100            this->isFloor_ = true;
101        } else {
102            this->isFloor_ = false;
103        }
104
105        return false;
106    }
107
108    /**
109    @brief
110        Makes the ship jump
111    @param bBoost
112    */
113    void HoverShip::boost(bool bBoost) {
114        if (bBoost && this->isFloor_)
115        {
116
117            this->setVelocity(
118                this->getVelocity().x,
119                jumpBoost_,
120                this->getVelocity().z
121                );
122            this->isFloor_ = false;
123        }
124    }
125
126    Hover* HoverShip::getGame()
127    {
128        if (game == nullptr)
129        {
130            for (Hover* hover : ObjectList<Hover>())
131                game = hover;
132        }
133        return game;
134    }
135
136    void HoverShip::death()
137    {
138        getGame()->costLife();
139        SpaceShip::death();
140    }
141}
Note: See TracBrowser for help on using the repository browser.