/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Viviane Yang * Co-authors: * ... * */ /* TODO: @file OrxoBloxShip.cc @brief Implementation of the OrxoBloxShip class. */ #include "OrxoBloxShip.h" #include "core/CoreIncludes.h" namespace orxonox { RegisterClass(OrxoBloxShip); OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context) { RegisterObject(OrxoBloxShip); this->bImmune = false; this->width = 120; this->height = 100; orxout() << "Spawned" << std::endl; //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this))); } //Use this function to display your position on the field -> to determine field width and height void OrxoBloxShip::showposition() { Vector3 pos = this->getPosition(); orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; } //Same thing for orientation void OrxoBloxShip::showorientation() { Quaternion ort = this->getOrientation(); orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl; } void OrxoBloxShip::tick(float dt) { SUPER(OrxoBloxShip, tick, dt); Vector3 pos = this->getPosition(); //ensure that the ship stays in playing field if(pos.x > width/2) pos.x = -width/2; if(pos.x < -width/2) pos.x = width/2; //2D movement, position should always = 0 on y-axis if(pos.y!=0) pos.y = 0; this->setPosition(pos); if(pos.z!=50) pos.z = 50; } OrxoBlox* OrxoBloxShip::getGame() { if (game == nullptr) { for (OrxoBlox* race : ObjectList()) { game = race; } } return game; } void OrxoBloxShip::death() { SpaceShip::death(); } }