/* 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: * Samuel Riedel * Co-authors: * ... * */ /** @file Asteroids2DStone.cc @brief Implementation of the Asteroids2DStone class. */ #include "Asteroids2DStone.h" #include "Asteroids2D.h" #include "Asteroids2DShip.h" #include "core/CoreIncludes.h" #include "util/Math.h" namespace orxonox { RegisterClass(Asteroids2DStone); Asteroids2DStone::Asteroids2DStone(Context* context) : Pawn(context) { RegisterObject(Asteroids2DStone); this->size = 1; this->width = 1043; this->height = 646; this->setPosition(randomPosition(this->width, this->height)); this->setVelocity(randomVelocity(MAX_SPEED)); } Vector3 Asteroids2DStone::randomPosition(float maxwidth, float maxheight) { Vector3 pos; pos.x = rnd(-maxwidth/2, maxwidth/2); pos.y = 0; pos.z = rnd(-maxheight/2, maxheight/2); return pos; } Vector3 Asteroids2DStone::randomVelocity(float maxspeed) { Vector3 vel; vel.x = rnd(maxspeed); vel.y = 0; vel.z = rnd(maxspeed); return vel; } void Asteroids2DStone::tick(float dt) { SUPER(Asteroids2DStone, tick, dt); Vector3 pos = this->getPosition(); if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2) { Quaternion orientation = this->getOrientation(); orientation.w -= 180; this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w)); } } //Overload kill function to generate 2 asteriods /*void Asteroids2DStone::kill() { this->damage(this->health) if(this->size < 1) { this->death(); }else{ size -= 1; } }*/ }