Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Boxhead_FS19/src/modules/hover/HoverShip.cc

Last change on this file was 12398, checked in by cwaupoti, 6 years ago

temorary

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