Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mergeFS18/src/modules/superorxobros/SOBTube.cc @ 12155

Last change on this file since 12155 was 12031, checked in by merholzl, 6 years ago

merged Tubes into SuperOrxoBros

File size: 3.7 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 *      Julien
24 *   Co-authors:
25 *     
26 *
27 */
28
29/**
30    @file SOBTube.cc
31     @brief Declaration of the SOBTube class.
32            This class is used for the tubes in the game. It adds the function that the figure can slip through Tube.
33*/
34
35#include "SOBTube.h"
36
37#include "core/CoreIncludes.h"
38#include "core/XMLPort.h"
39#include "SOBFigure.h"
40#include "util/Output.h"
41#include "objects/collisionshapes/BoxCollisionShape.h"
42
43
44namespace orxonox
45{
46    RegisterClass(SOBTube);
47
48    SOBTube::SOBTube(Context* context) : MovableEntity(context)
49    {
50        RegisterObject(SOBTube);
51        setAngularFactor(0.0);
52        this->enableCollisionCallback();
53        k=0;u=0;                        //initializing variables for tick function
54        a=CollisionType::None;          //initializing Collisiontypes for tick function
55        b=CollisionType::Dynamic;       //initializing Collisiontypes for tick function
56        movedown=false;                 //initializing variable movedown (movedown is used for allowing figure to get through tube)
57        hasCollided_=false;             //initializing variable
58       
59        left = new BoxCollisionShape(context);  //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others)
60        left->setHalfExtents(Vector3(10, 10, 30));// set CollisionShape
61        attachCollisionShape(left);             //attach CollisionShape
62       
63         
64       
65    }
66   
67
68   
69
70    void SOBTube::XMLPort(Element& xmlelement, XMLPort::Mode mode) //set parameters for SOB.oxw file
71    {
72        SUPER(SOBTube, XMLPort, xmlelement, mode);
73        XMLPortParam(SOBTube,"cool",getcool,setcool,xmlelement,mode); 
74       
75
76
77    }
78
79   
80    bool SOBTube::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
81         
82         
83         
84
85        return true;
86    }
87
88     void SOBTube::tick(float dt)
89    {
90        SUPER(SOBTube, tick, dt);
91        Vector3 velocity = getVelocity(); //velocity of tube
92        Vector3 position = getPosition(); //position of tube
93        position.y=0;                     //position in y axes must be 0
94
95        setPosition(position);     //set new position of tube
96        velocity.z = 0*dt;         //velocity in all directions must be 0 or else tube is moving
97        velocity.y = 0*dt;
98        velocity.x = 0*dt;
99        setVelocity(velocity);     //set new velocity
100       
101       
102
103       
104           
105        if(movedown && k==0){                       //if movedown is allowed change Collisiontype from dynamic to None
106            CollisionType a = CollisionType::None;
107            this->setCollisionType(a);                   
108
109         
110            k++;
111        }
112       if(k!=0){u++;}
113
114        if(u>=50){
115            this->setCollisionType(b);k=0;u=0;movedown=false; //set Collisiontype from None to dynamic
116        }
117    }
118   
119
120   
121}
Note: See TracBrowser for help on using the repository browser.