Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10960 was 10960, checked in by maxima, 8 years ago

Merged presentation and hover branches. Hover minigame works fine.

File size: 3.6 KB
RevLine 
[10657]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:
[10659]23 *      Cyrill Burgener
[10657]24 *
25 */
26
27/**
[10659]28    @file HoverShip.cc
[10929]29    @brief Implementation of the HoverShip control
[10657]30*/
31
[10659]32#include "HoverShip.h"
[10657]33#include "core/CoreIncludes.h"
34
35namespace orxonox
36{
[10659]37    RegisterClass(HoverShip);
[10657]38
[10659]39    HoverShip::HoverShip(Context* context) : SpaceShip(context)
[10657]40    {
[10659]41        RegisterObject(HoverShip);
[10784]42        enableCollisionCallback();
43        isFloor_ = false;
[10657]44    }
45
[10659]46    void HoverShip::tick(float dt)
[10657]47    {
[10659]48        SUPER(HoverShip, tick, dt);
[10657]49    }
50
[10784]51    void HoverShip::moveFrontBack(const Vector2& value)
52        { this->steering_.z -= value.x; }
[10694]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
[10784]60    void HoverShip::rotateYaw(const Vector2& value)
61    {
62        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
[10694]63
[10784]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
[10929]74    /**
75    @brief
76        sets this ships jumpBoost
77    @param jumpBoost
78    */
[10784]79    void HoverShip::setJumpBoost(float jumpBoost)
80    {
81        this->jumpBoost_ = jumpBoost;
82    }
83
[10929]84    /**
85    @brief
86        returns this ships jumpBoost
87    @returns jumpBoost
88    */
[10784]89    float HoverShip::getJumpBoost()
90    {
91        return jumpBoost_;
92    }
93
94    /**
95    @brief
[10929]96        Removed, does nothing.
[10784]97    @param value
98    */
99    void HoverShip::rotatePitch(const Vector2& value) { }
100
101    /**
102    @brief
[10929]103        Removed, does nothing.
[10784]104    @param value
105    */
106    void HoverShip::rotateRoll(const Vector2& value) { }
107
[10929]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    */
[10760]112    bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
[10694]113    {
[10784]114        SpaceShip::collidesAgainst(otherObject, cs, contactPoint);
115        //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint);
[10760]116
[10784]117        if (contactPoint.m_normalWorldOnB.y() > 0.6
118            && this->getVelocity().y < 1) {
[10694]119            this->isFloor_ = true;
[10784]120        } else {
[10694]121            this->isFloor_ = false;
[10784]122        }
[10694]123
124        return false;
125    }
126
[10929]127    /**
128    @brief
129        Makes the ship jump
130    @param bBoost
131    */
[10694]132    void HoverShip::boost(bool bBoost) {
[10784]133        if (bBoost && this->isFloor_)
[10694]134        {
[10784]135            this->setVelocity(
136                this->getVelocity().x,
137                jumpBoost_,
138                this->getVelocity().z
139                );
[10694]140            this->isFloor_ = false;
[10784]141        }
[10694]142    }
[10657]143}
Note: See TracBrowser for help on using the repository browser.