/* * 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: * Julien * Co-authors: * * */ /** @file SOBTube.cc @brief Declaration of the SOBTube class. This class is used for the tubes in the game. It adds the function that the figure can slip through Tube. */ #include "SOBTubeCactus.h" #include "core/CoreIncludes.h" #include "core/XMLPort.h" #include "SOBFigure.h" #include "util/Output.h" #include "objects/collisionshapes/BoxCollisionShape.h" namespace orxonox { RegisterClass(SOBTubeCactus); SOBTubeCactus::SOBTubeCactus(Context* context) : MovableEntity(context) { RegisterObject(SOBTubeCactus); setAngularFactor(0.0); this->enableCollisionCallback(); k=0;u=0; //initializing variables for tick function a=CollisionType::None; //initializing Collisiontypes for tick function b=CollisionType::Dynamic; //initializing Collisiontypes for tick function //movedown=false; //initializing variable movedown (movedown is used for allowing figure to get through tube) hasCollided_=false; //initializing variable left = new BoxCollisionShape(context); //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others) left->setHalfExtents(Vector3(10, 10, 26));// set CollisionShape attachCollisionShape(left); //attach CollisionShape } void SOBTubeCactus::XMLPort(Element& xmlelement, XMLPort::Mode mode) //set parameters for SOB.oxw file { SUPER(SOBTubeCactus, XMLPort, xmlelement, mode); XMLPortParam(SOBTubeCactus,"cool",getcool,setcool,xmlelement,mode); } bool SOBTubeCactus::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { return true; } void SOBTubeCactus::tick(float dt) { SUPER(SOBTube, tick, dt); Vector3 velocity = getVelocity(); //velocity of tube Vector3 position = getPosition(); //position of tube position.y=0; //position in y axes must be 0 setPosition(position); //set new position of tube velocity.z = 0*dt; //velocity in all directions must be 0 or else tube is moving velocity.y = 0*dt; velocity.x = 0*dt; setVelocity(velocity); //set new velocity /* if(movedown && k==0){ //if movedown is allowed change Collisiontype from dynamic to None CollisionType a = CollisionType::None; this->setCollisionType(a); k++; } if(k!=0){u++;} if(u>=50){ this->setCollisionType(b);k=0;u=0;movedown=false; //set Collisiontype from None to dynamic } */ } }