[12298] | 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 | * Viviane Yang |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /* TODO: |
---|
| 30 | |
---|
| 31 | @file OrxoBloxShip.cc |
---|
| 32 | @brief Implementation of the OrxoBloxShip class. |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | #include "OrxoBloxShip.h" |
---|
[12367] | 36 | #include "OrxoBlox.h" |
---|
[12298] | 37 | #include "core/CoreIncludes.h" |
---|
| 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
| 41 | RegisterClass(OrxoBloxShip); |
---|
| 42 | |
---|
| 43 | OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context) |
---|
| 44 | { |
---|
| 45 | RegisterObject(OrxoBloxShip); |
---|
| 46 | |
---|
| 47 | this->bImmune = false; |
---|
| 48 | this->width = 120; |
---|
| 49 | this->height = 100; |
---|
[12367] | 50 | orxout() << "SPACESHIP Spawned" << std::endl; |
---|
[12298] | 51 | |
---|
| 52 | //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this))); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | //Use this function to display your position on the field -> to determine field width and height |
---|
| 56 | void OrxoBloxShip::showposition() |
---|
| 57 | { |
---|
| 58 | Vector3 pos = this->getPosition(); |
---|
| 59 | orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | //Same thing for orientation |
---|
| 63 | void OrxoBloxShip::showorientation() |
---|
| 64 | { |
---|
| 65 | Quaternion ort = this->getOrientation(); |
---|
| 66 | orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void OrxoBloxShip::tick(float dt) |
---|
| 70 | { |
---|
| 71 | Vector3 pos = this->getPosition(); |
---|
[12391] | 72 | |
---|
| 73 | //ensure that the ship stays in playing field |
---|
| 74 | if(pos.x > width/2) pos.x = -width/2; |
---|
| 75 | if(pos.x < -width/2) pos.x = width/2; |
---|
| 76 | if(pos.z > height/2) pos.z = -height/2; |
---|
| 77 | if(pos.z < -height/2) pos.z = height/2; |
---|
| 78 | |
---|
| 79 | //2D movement, position should always = 0 on y-axis |
---|
| 80 | if(pos.y!=0) pos.y = 0; |
---|
[12370] | 81 | this->setPosition(pos); |
---|
[12391] | 82 | |
---|
| 83 | |
---|
| 84 | //if you hit an asteroid, the ship will turn -> you need to reorientate the ship |
---|
| 85 | Quaternion ort = this->getOrientation(); |
---|
| 86 | ort.x = 0; |
---|
| 87 | ort.z = 0; |
---|
| 88 | this->setOrientation(ort); |
---|
[12370] | 89 | } |
---|
[12298] | 90 | |
---|
[12370] | 91 | void OrxoBloxShip::boost(bool bBoost) |
---|
| 92 | { |
---|
[12298] | 93 | } |
---|
| 94 | |
---|
| 95 | } |
---|
[12367] | 96 | |
---|