Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/JumpProjectile.cc @ 10050

Last change on this file since 10050 was 10050, checked in by fvultier, 10 years ago

Added a whole bunch of code

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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file JumpProjectile.cc
31    @brief Implementation of the JumpProjectile class.
32*/
33
34#include "JumpProjectile.h"
35
36#include "core/CoreIncludes.h"
37#include "core/GameMode.h"
38#include "graphics/Model.h"
39#include "gametypes/Gametype.h"
40
41#include "JumpFigure.h"
42
43#include "sound/WorldSound.h"
44#include "core/XMLPort.h"
45
46namespace orxonox
47{
48    RegisterClass(JumpProjectile);
49
50    /**
51    @brief
52        Constructor. Registers and initializes the object.
53    */
54    JumpProjectile::JumpProjectile(Context* context) : MovableEntity(context)
55    {
56        RegisterObject(JumpProjectile);
57
58        this->figure_ = 0;
59
60        this->registerVariables();
61
62        this->setPosition(Vector3(0,0,0));
63        this->setVelocity(Vector3(0,0,0));
64        this->setAcceleration(Vector3(0,0,0));
65    }
66
67    /**
68    @brief
69        Destructor.
70    */
71    JumpProjectile::~JumpProjectile()
72    {
73        /*if (this->isInitialized())
74        {
75            if (this->bDeleteBats_)
76                delete this->figure_;
77
78            delete[] this->batID_;
79        }*/
80    }
81
82    //xml port for loading sounds
83    void JumpProjectile::XMLPort(Element& xmlelement, XMLPort::Mode mode)
84    {
85        SUPER(JumpProjectile, XMLPort, xmlelement, mode);
86    }
87
88    /**
89    @brief
90        Register variables to synchronize over the network.
91    */
92    void JumpProjectile::registerVariables()
93    {
94        registerVariable( this->fieldWidth_ );
95        registerVariable( this->fieldHeight_ );
96        //registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<JumpProjectile>( this, &JumpProjectile::applyBats) );
97    }
98
99    /**
100    @brief
101        Is called every tick.
102        Handles the movement of the ball and its interaction with the boundaries and bats.
103    @param dt
104        The time since the last tick.
105    */
106    void JumpProjectile::tick(float dt)
107    {
108        SUPER(JumpProjectile, tick, dt);
109
110        Vector3 platformPosition = this->getPosition();
111
112        if (figure_ != NULL)
113        {
114            Vector3 figurePosition = figure_->getPosition();
115            Vector3 figureVelocity = figure_->getVelocity();
116
117            if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-10 && figurePosition.x < platformPosition.x+10 && figurePosition.z > platformPosition.z-4 && figurePosition.z < platformPosition.z+4)
118            {
119                touchFigure();
120            }
121        }
122    }
123
124    /**
125    @brief
126        Set the bats for the ball.
127    @param bats
128        An array (of size 2) of weak pointers, to be set as the new bats.
129    */
130    void JumpProjectile::setFigure(WeakPtr<JumpFigure> newFigure)
131    {
132        figure_ = newFigure;
133    }
134
135    void JumpProjectile::accelerateFigure()
136    {
137
138    }
139
140    void JumpProjectile::touchFigure()
141    {
142
143    }
144}
Note: See TracBrowser for help on using the repository browser.