Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc @ 11616

Last change on this file since 11616 was 11616, checked in by vyang, 6 years ago

Asteroids2DStones erstellt, lassen sich ins Level laden, random spawn wenn position nicht als Attribut im XML File angegeben wird. Random Geschwindigkeit funktioniert noch nicht → vllt Einstellungen in Pawn bzw MovableEntity?, Gametype ein wenig aufgeraemt → am Anfang fuenf Asteroiden mit random Geschwindigkeit und Position spawnen

File size: 2.6 KB
Line 
1/*   ORXONOX - the hottest 3D action shooter ever to exist
2 *                    > www.orxonox.net <
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Samuel Riedel
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29    @file Asteroids2DStone.cc
30    @brief Implementation of the Asteroids2DStone class.
31*/
32
33#include "Asteroids2DStone.h"
34#include "Asteroids2D.h"
35#include "Asteroids2DShip.h"
36#include "core/CoreIncludes.h"
37#include "util/Math.h"
38
39namespace orxonox
40{
41    RegisterClass(Asteroids2DStone);
42
43    Asteroids2DStone::Asteroids2DStone(Context* context) : Pawn(context)
44    {
45        RegisterObject(Asteroids2DStone);
46        this->size = 1;
47        this->width = 1043;
48        this->height = 646;
49        this->setPosition(randomPosition(this->width, this->height));
50        this->setVelocity(randomVelocity(MAX_SPEED));
51    }
52
53    Vector3 Asteroids2DStone::randomPosition(float maxwidth, float maxheight)
54    {
55        Vector3 pos;
56        pos.x = rnd(-maxwidth/2, maxwidth/2);
57        pos.y = 0;
58        pos.z = rnd(-maxheight/2, maxheight/2);
59        return pos;
60    }
61
62    Vector3 Asteroids2DStone::randomVelocity(float maxspeed)
63    {
64        Vector3 vel;
65        vel.x = rnd(maxspeed);
66        vel.y = 0;
67        vel.z = rnd(maxspeed);
68        return vel;
69    }
70
71
72    void Asteroids2DStone::tick(float dt)
73    {
74        SUPER(Asteroids2DStone, tick, dt);
75        Vector3 pos = this->getPosition();
76        if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2)
77        {
78            Quaternion orientation = this->getOrientation();
79            orientation.w -= 180;
80            this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w));
81        }
82
83    }
84
85
86    //Overload kill function to generate 2 asteriods
87    /*void Asteroids2DStone::kill()
88    {
89        this->damage(this->health)
90        if(this->size < 1)
91        {
92            this->death();
93        }else{
94            size -= 1;
95
96        }
97
98
99    }*/
100
101
102}
Note: See TracBrowser for help on using the repository browser.