/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Florian Zinggeler * Co-authors: * ... * */ /** @file AsteroidsEnemy.h @brief Declaration of the AsteroidsEnemy class. */ #include "AsteroidsStone.h" #include "core/CoreIncludes.h" #include "Asteroids.h" #include "AsteroidsShip.h" #include #include #include "util/Math.h" const float delta = 3; namespace orxonox { RegisterClass(AsteroidsStone); //pawn kann sterben -> nach dem Tot sollen aber 2 Asteroiden spawnen AsteroidsStone::AsteroidsStone(Context* context) : Pawn(context) { RegisterObject(AsteroidsStone); direction = 0; //Spielfeld x als Horizontale und z als Vertikale fieldWidth_ = this->getGame()->center_->getFieldWidth; fieldHeigth_ = this->getGame()->center_->getFieldHeight; //Random size 1, 2, 3 ->muss noch realisiert werden. Templates erstellen this.size = 1; maxspeed = 50.0f; //Random Spawn? pos= random? -> spawn durch timer in der Asteroids Klasse this->setPosition(rnd(fieldWidth_), 0, rnd(fieldHeigth)); //random Geschwindigkeit und Richtung velocity.x = rnd(maxspeed); velocity.y = rnd(maxspeed); } inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { if(orxonox_cast(otherObject)) removeHealth(2000); return false; } void Asteroids::death() { if(this->size == 1){ Pawn::death(); }else if(this->size == 2){ Pawn::death(); //Wie mache ich das ? Eigentlich in der game Klasse? sonst zeigt der Pointer auf einen falschen Bereich for(int i = 0; i<2; i++) { AsteroidsStone* newStone; newStone = new AsteroidsStone(this->getGame()->center_->getContext()); newStone->addTemplate("asteroidsstone"); newStone->setAsteroidsPlayer(this->getGame()->player); } } } Asteroids* AsteroidsStone::getGame() { if (game == nullptr) { for (Asteroids* Asteroids : ObjectList()) game = asteroids; } return game; } //Bis hier geschrieben void AsteroidsStone::tick(float dt) { Vector3 pos = getPosition(); //bounce on the borders if(pos.x-delta <= 0 || pos.x+delta >= fieldWidth_) direction = -direction; //zurück bringen if(pos.y != 0){ pos.y=0; } //spin setOrientation() setPosition(pos); SUPER(AsteroidsStone, tick, dt); } inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { if(orxonox_cast(otherObject)) removeHealth(2000); return false; } }