[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" |
---|
| 36 | #include "core/CoreIncludes.h" |
---|
| 37 | |
---|
| 38 | namespace orxonox |
---|
| 39 | { |
---|
| 40 | RegisterClass(OrxoBloxShip); |
---|
| 41 | |
---|
| 42 | OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context) |
---|
| 43 | { |
---|
| 44 | RegisterObject(OrxoBloxShip); |
---|
| 45 | |
---|
| 46 | this->bImmune = false; |
---|
| 47 | this->width = 120; |
---|
| 48 | this->height = 100; |
---|
[12337] | 49 | orxout() << "Spawned" << std::endl; |
---|
[12298] | 50 | |
---|
| 51 | //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this))); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | //Use this function to display your position on the field -> to determine field width and height |
---|
| 55 | void OrxoBloxShip::showposition() |
---|
| 56 | { |
---|
| 57 | Vector3 pos = this->getPosition(); |
---|
| 58 | orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | //Same thing for orientation |
---|
| 62 | void OrxoBloxShip::showorientation() |
---|
| 63 | { |
---|
| 64 | Quaternion ort = this->getOrientation(); |
---|
| 65 | orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | void OrxoBloxShip::tick(float dt) |
---|
| 69 | { |
---|
| 70 | SUPER(OrxoBloxShip, tick, dt); |
---|
| 71 | Vector3 pos = this->getPosition(); |
---|
| 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 | |
---|
| 77 | //2D movement, position should always = 0 on y-axis |
---|
| 78 | if(pos.y!=0) pos.y = 0; |
---|
| 79 | this->setPosition(pos); |
---|
| 80 | if(pos.z!=50) pos.z = 50; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | OrxoBlox* OrxoBloxShip::getGame() |
---|
| 84 | { |
---|
| 85 | if (game == nullptr) |
---|
| 86 | { |
---|
| 87 | for (OrxoBlox* race : ObjectList<OrxoBlox>()) |
---|
| 88 | { |
---|
| 89 | game = race; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | return game; |
---|
| 93 | } |
---|
| 94 | void OrxoBloxShip::death() |
---|
| 95 | { |
---|
| 96 | SpaceShip::death(); |
---|
| 97 | } |
---|
| 98 | } |
---|