Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc @ 11555

Last change on this file since 11555 was 11555, checked in by vyang, 7 years ago

Level file: korrekte Kameraposition, Raumschiff bewegt sich nicht, schiesst aber → wird AsteroidsShip ueberhaupt geladen? AsteroidsShip: neue Steuerung (vgl Jump, Rotation muss noch angepasst werden)

File size: 3.8 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 *      Florian Zinggeler
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file AsteroidsEnemy.h
31    @brief Declaration of the AsteroidsEnemy class.
32*/
33
34#include "AsteroidsStone.h"
35#include "core/CoreIncludes.h"
36#include "Asteroids.h"
37#include "AsteroidsShip.h"
38#include <cstdlib>
39#include <cmath>
40#include "util/Math.h"
41
42const float delta = 3;
43
44namespace orxonox
45{
46    RegisterClass(AsteroidsStone);
47    //pawn kann sterben -> nach dem Tot sollen aber 2 Asteroiden spawnen
48    AsteroidsStone::AsteroidsStone(Context* context) : Pawn(context)
49    {
50        RegisterObject(AsteroidsStone);
51
52        direction = 0;
53        //Spielfeld x als Horizontale und z als Vertikale
54        fieldWidth_ = this->getGame()->center_->getFieldWidth;
55        fieldHeigth_ = this->getGame()->center_->getFieldHeight;
56
57
58        //Random size 1, 2, 3 ->muss noch realisiert werden. Templates erstellen
59        this.size = 1;
60        maxspeed = 50.0f;
61        //Random Spawn? pos= random? -> spawn durch timer in der Asteroids Klasse
62        this->setPosition(rnd(fieldWidth_), 0, rnd(fieldHeigth));
63
64        //random Geschwindigkeit und Richtung
65        velocity.x = rnd(maxspeed);
66        velocity.y = rnd(maxspeed);
67    }
68
69    inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
70    {
71        if(orxonox_cast<AsteroidsShip*>(otherObject))
72            removeHealth(2000);
73        return false;
74    }
75
76    void Asteroids::death()
77    {
78        if(this->size == 1){
79            Pawn::death();
80        }else if(this->size == 2){
81            Pawn::death();
82            //Wie mache ich das ? Eigentlich in der game Klasse? sonst zeigt der Pointer auf einen falschen Bereich
83            for(int i = 0; i<2; i++)
84            {
85                AsteroidsStone* newStone;
86                newStone = new AsteroidsStone(this->getGame()->center_->getContext());
87                newStone->addTemplate("asteroidsstone");
88                newStone->setAsteroidsPlayer(this->getGame()->player);
89            }
90
91        }
92    }
93   
94
95    Asteroids* AsteroidsStone::getGame()
96    {
97        if (game == nullptr)
98        {
99            for (Asteroids* Asteroids : ObjectList<Asteroids>())
100                game = asteroids;
101        }
102        return game;
103    }
104
105
106//Bis hier geschrieben
107    void AsteroidsStone::tick(float dt)
108    {
109        Vector3 pos = getPosition();
110
111
112
113
114        //bounce on the borders
115        if(pos.x-delta <= 0 || pos.x+delta >= fieldWidth_)
116            direction = -direction;
117
118
119
120        //zurück bringen
121        if(pos.y != 0){
122            pos.y=0;
123        }
124
125        //spin
126
127        setOrientation()
128        setPosition(pos);
129
130        SUPER(AsteroidsStone, tick, dt);
131    }
132
133    inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
134    {
135        if(orxonox_cast<AsteroidsShip*>(otherObject))
136            removeHealth(2000);
137        return false;
138    }
139
140
141}
Note: See TracBrowser for help on using the repository browser.