Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS15/src/modules/hover/HoverShip.cc @ 11030

Last change on this file since 11030 was 11026, checked in by landauf, 9 years ago

eol-style:native

  • Property svn:eol-style set to native
File size: 3.6 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
35namespace orxonox
36{
37    RegisterClass(HoverShip);
38
39    HoverShip::HoverShip(Context* context) : SpaceShip(context)
40    {
41        RegisterObject(HoverShip);
42        enableCollisionCallback();
43        isFloor_ = false;
44    }
45
46    void HoverShip::tick(float dt)
47    {
48        SUPER(HoverShip, tick, dt);
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        sets this ships jumpBoost
77    @param jumpBoost
78    */
79    void HoverShip::setJumpBoost(float jumpBoost)
80    {
81        this->jumpBoost_ = jumpBoost;
82    }
83
84    /**
85    @brief
86        returns this ships jumpBoost
87    @returns jumpBoost
88    */
89    float HoverShip::getJumpBoost()
90    {
91        return jumpBoost_;
92    }
93
94    /**
95    @brief
96        Removed, does nothing.
97    @param value
98    */
99    void HoverShip::rotatePitch(const Vector2& value) { }
100
101    /**
102    @brief
103        Removed, does nothing.
104    @param value
105    */
106    void HoverShip::rotateRoll(const Vector2& value) { }
107
108    /**
109    @brief
110        Checks if the ship is touching the floor. The ship can only jump if there is contact with someting beneath it.
111    */
112    bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
113    {
114        SpaceShip::collidesAgainst(otherObject, cs, contactPoint);
115        //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint);
116
117        if (contactPoint.m_normalWorldOnB.y() > 0.6
118            && this->getVelocity().y < 1) {
119            this->isFloor_ = true;
120        } else {
121            this->isFloor_ = false;
122        }
123
124        return false;
125    }
126
127    /**
128    @brief
129        Makes the ship jump
130    @param bBoost
131    */
132    void HoverShip::boost(bool bBoost) {
133        if (bBoost && this->isFloor_)
134        {
135            this->setVelocity(
136                this->getVelocity().x,
137                jumpBoost_,
138                this->getVelocity().z
139                );
140            this->isFloor_ = false;
141        }
142    }
143}
Note: See TracBrowser for help on using the repository browser.