Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12298 was 12298, checked in by pomselj, 5 years ago

We got a Ship!

File size: 2.7 KB
Line 
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 "OrxoBloxShip.h"
37#include "core/CoreIncludes.h"
38
39namespace orxonox
40{
41    RegisterClass(OrxoBloxShip);
42
43    OrxoBloxShip::OrxoBloxShip(Context* context) : SpaceShip(context)
44    {
45        RegisterObject(OrxoBloxShip);
46
47        this->bImmune = false;
48        this->width = 120;
49        this->height = 100;
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}
Note: See TracBrowser for help on using the repository browser.