Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

new items added. improved level generator.

File size: 3.6 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        figure_ = 0;
59
60        registerVariables();
61
62        setPosition(Vector3(0,0,0));
63        setVelocity(Vector3(0,0,250.0));
64        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 projectilePosition = getPosition();
111
112                for (ObjectList<JumpEnemy>::iterator it = ObjectList<JumpEnemy>::begin(); it != ObjectList<JumpEnemy>::end(); ++it)
113                {
114                        Vector3 enemyPosition = it->getPosition();
115                        float enemyWidth = it->getWidth();
116                        float enemyHeight = it->getHeight();
117
118                        if(projectilePosition.x > enemyPosition.x-enemyWidth && projectilePosition.x < enemyPosition.x+enemyWidth && projectilePosition.z > enemyPosition.z-enemyHeight && projectilePosition.z < enemyPosition.z+enemyHeight)
119                        {
120                                it->dead_ = true;
121                        }
122                }
123    }
124
125    /**
126    @brief
127        Set the bats for the ball.
128    @param bats
129        An array (of size 2) of weak pointers, to be set as the new bats.
130    */
131    void JumpProjectile::setFigure(WeakPtr<JumpFigure> figure)
132    {
133        figure_ = figure;
134    }
135}
Note: See TracBrowser for help on using the repository browser.