[12298] | 1 | #include "OrxoBloxShip.h" |
---|
[12367] | 2 | #include "OrxoBlox.h" |
---|
[12298] | 3 | #include "core/CoreIncludes.h" |
---|
| 4 | |
---|
| 5 | namespace orxonox |
---|
| 6 | { |
---|
| 7 | RegisterClass(OrxoBloxShip); |
---|
| 8 | |
---|
| 9 | OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context) |
---|
| 10 | { |
---|
| 11 | RegisterObject(OrxoBloxShip); |
---|
| 12 | |
---|
| 13 | this->bImmune = false; |
---|
| 14 | this->width = 120; |
---|
| 15 | this->height = 100; |
---|
[12367] | 16 | orxout() << "SPACESHIP Spawned" << std::endl; |
---|
[12298] | 17 | |
---|
| 18 | //timer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxoBloxShip::showorientation, this))); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | //Use this function to display your position on the field -> to determine field width and height |
---|
| 22 | void OrxoBloxShip::showposition() |
---|
| 23 | { |
---|
| 24 | Vector3 pos = this->getPosition(); |
---|
| 25 | orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | //Same thing for orientation |
---|
| 29 | void OrxoBloxShip::showorientation() |
---|
| 30 | { |
---|
| 31 | Quaternion ort = this->getOrientation(); |
---|
| 32 | orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | void OrxoBloxShip::tick(float dt) |
---|
| 36 | { |
---|
| 37 | Vector3 pos = this->getPosition(); |
---|
[12391] | 38 | |
---|
| 39 | //ensure that the ship stays in playing field |
---|
| 40 | if(pos.x > width/2) pos.x = -width/2; |
---|
| 41 | if(pos.x < -width/2) pos.x = width/2; |
---|
| 42 | if(pos.z > height/2) pos.z = -height/2; |
---|
| 43 | if(pos.z < -height/2) pos.z = height/2; |
---|
| 44 | |
---|
| 45 | //2D movement, position should always = 0 on y-axis |
---|
| 46 | if(pos.y!=0) pos.y = 0; |
---|
[12370] | 47 | this->setPosition(pos); |
---|
[12391] | 48 | |
---|
| 49 | |
---|
| 50 | //if you hit an asteroid, the ship will turn -> you need to reorientate the ship |
---|
| 51 | Quaternion ort = this->getOrientation(); |
---|
| 52 | ort.x = 0; |
---|
| 53 | ort.z = 0; |
---|
| 54 | this->setOrientation(ort); |
---|
[12370] | 55 | } |
---|
[12298] | 56 | |
---|
[12370] | 57 | void OrxoBloxShip::boost(bool bBoost) |
---|
| 58 | { |
---|
[12298] | 59 | } |
---|
| 60 | |
---|
| 61 | } |
---|
[12367] | 62 | |
---|