#include "OrxoBloxShip.h" #include "OrxoBlox.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() << "SPACESHIP 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) { 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; if(pos.z > height/2) pos.z = -height/2; if(pos.z < -height/2) pos.z = height/2; //2D movement, position should always = 0 on y-axis if(pos.y!=0) pos.y = 0; this->setPosition(pos); //if you hit an asteroid, the ship will turn -> you need to reorientate the ship Quaternion ort = this->getOrientation(); ort.x = 0; ort.z = 0; this->setOrientation(ort); } void OrxoBloxShip::boost(bool bBoost) { } }