Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/jump/JumpPlatform.cc @ 10768

Last change on this file since 10768 was 10632, checked in by fvultier, 9 years ago

Removed useless code (artifacts from copy-paste) in the Jump minigame.

  • Property svn:eol-style set to native
File size: 3.1 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 *      Fabien Vultier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file JumpPlatform.cc
31    @brief All platforms in this minigame inherit from this class. The basic functions of a platform (interact with figure) is implemented here. Special functions are implemented in the specialized classes.
32*/
33
34#include "JumpPlatform.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(JumpPlatform);
49
50    JumpPlatform::JumpPlatform(Context* context) : MovableEntity(context)
51    {
52        RegisterObject(JumpPlatform);
53
54        figure_ = 0;
55
56        setPosition(Vector3(0,0,0));
57        setVelocity(Vector3(0,0,0));
58        setAcceleration(Vector3(0,0,0));
59    }
60
61    /**
62    @brief
63        Destructor.
64    */
65    JumpPlatform::~JumpPlatform()
66    {
67
68    }
69
70    //xml port for loading height and width of the platform
71    void JumpPlatform::XMLPort(Element& xmlelement, XMLPort::Mode mode)
72    {
73        SUPER(JumpPlatform, XMLPort, xmlelement, mode);
74
75        XMLPortParam(JumpPlatform, "height", setHeight, getHeight, xmlelement, mode);
76        XMLPortParam(JumpPlatform, "width", setWidth, getWidth, xmlelement, mode);
77    }
78
79    /**
80    @brief
81        Is called every tick.
82        Handles the movement of the ball and its interaction with the boundaries and bats.
83    @param dt
84        The time since the last tick.
85    */
86    void JumpPlatform::tick(float dt)
87    {
88        SUPER(JumpPlatform, tick, dt);
89
90        Vector3 platformPosition = this->getPosition();
91
92        if (figure_ != NULL)
93        {
94            Vector3 figurePosition = figure_->getPosition();
95            Vector3 figureVelocity = figure_->getVelocity();
96
97            float tolerance = 3.0;
98
99            if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-width_/2 && figurePosition.x < platformPosition.x+width_/2 && figurePosition.z > platformPosition.z-height_/2*tolerance && figurePosition.z < platformPosition.z+height_/2)
100            {
101                touchFigure();
102            }
103        }
104    }
105
106    void JumpPlatform::setFigure(JumpFigure* newFigure)
107    {
108        figure_ = newFigure;
109    }
110
111    void JumpPlatform::touchFigure()
112    {
113
114    }
115}
Note: See TracBrowser for help on using the repository browser.