Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11151 was 11151, checked in by tgidron, 8 years ago

New Level Up

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