Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartKart.cc @ 12095

Last change on this file since 12095 was 12066, checked in by emustafa, 6 years ago

OrxoKartKart controls optimized

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