Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxShip.cc @ 12397

Last change on this file since 12397 was 12396, checked in by pomselj, 6 years ago

Jesus safed our souls and stopped the crashing. Hallowed be his name and hallowed be his followers sevy and aryo, first of their names, saviors of the andals the raynars and the first nerds. Fourier is love btw

File size: 1.7 KB
Line 
1#include "OrxoBloxShip.h"
2#include "OrxoBlox.h"
3#include "core/CoreIncludes.h"
4
5namespace 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;
16        orxout() << "SPACESHIP Spawned" << std::endl;
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();
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;
47        this->setPosition(pos);
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);
55    }   
56
57    void OrxoBloxShip::boost(bool bBoost)
58    {
59    }
60
61}
62
Note: See TracBrowser for help on using the repository browser.