Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Pickups work; Lives Counter and Total Flag Counter

  • Property svn:eol-style set to native
File size: 3.7 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"
[11041]34#include "core/XMLPort.h"
[11171]35#include "Hover.h"
[11151]36//#include "NewHumanController.h"
[10657]37
[11041]38#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
39
[10657]40namespace orxonox
41{
[10659]42    RegisterClass(HoverShip);
[10657]43
[10659]44    HoverShip::HoverShip(Context* context) : SpaceShip(context)
[10657]45    {
[10659]46        RegisterObject(HoverShip);
[10784]47        enableCollisionCallback();
48        isFloor_ = false;
[11041]49        jumpBoost_ = 0;
[10657]50    }
51
[10784]52    void HoverShip::moveFrontBack(const Vector2& value)
53        { this->steering_.z -= value.x; }
[10694]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
[10784]61    void HoverShip::rotateYaw(const Vector2& value)
62    {
63        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
[10694]64
[10784]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
[10929]75    /**
76    @brief
77        Removed, does nothing.
[10784]78    @param value
79    */
80    void HoverShip::rotatePitch(const Vector2& value) { }
81
82    /**
83    @brief
[10929]84        Removed, does nothing.
[10784]85    @param value
86    */
87    void HoverShip::rotateRoll(const Vector2& value) { }
88
[10929]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    */
[10760]93    bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
[10694]94    {
[10784]95        SpaceShip::collidesAgainst(otherObject, cs, contactPoint);
96        //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint);
[10760]97
[10784]98        if (contactPoint.m_normalWorldOnB.y() > 0.6
99            && this->getVelocity().y < 1) {
[10694]100            this->isFloor_ = true;
[10784]101        } else {
[10694]102            this->isFloor_ = false;
[10784]103        }
[10694]104
105        return false;
106    }
107
[10929]108    /**
109    @brief
110        Makes the ship jump
111    @param bBoost
112    */
[10694]113    void HoverShip::boost(bool bBoost) {
[10784]114        if (bBoost && this->isFloor_)
[10694]115        {
[11151]116
[10784]117            this->setVelocity(
118                this->getVelocity().x,
119                jumpBoost_,
120                this->getVelocity().z
121                );
[10694]122            this->isFloor_ = false;
[10784]123        }
[10694]124    }
[11171]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    }
[10657]141}
Note: See TracBrowser for help on using the repository browser.