Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ProtectBoss_HS17/src/modules/jump/JumpPlatform.cc @ 11783

Last change on this file since 11783 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • 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 "core/XMLPort.h"
39#include "sound/WorldSound.h"
40#include "JumpFigure.h"
41
42namespace orxonox
43{
44    RegisterClass(JumpPlatform);
45
46    JumpPlatform::JumpPlatform(Context* context) : MovableEntity(context)
47    {
48        RegisterObject(JumpPlatform);
49
50        figure_ = nullptr;
51
52        setPosition(Vector3(0,0,0));
53        setVelocity(Vector3(0,0,0));
54        setAcceleration(Vector3(0,0,0));
55    }
56
57    /**
58    @brief
59        Destructor.
60    */
61    JumpPlatform::~JumpPlatform()
62    {
63
64    }
65
66    //xml port for loading height and width of the platform
67    void JumpPlatform::XMLPort(Element& xmlelement, XMLPort::Mode mode)
68    {
69        SUPER(JumpPlatform, XMLPort, xmlelement, mode);
70
71        XMLPortParam(JumpPlatform, "height", setHeight, getHeight, xmlelement, mode);
72        XMLPortParam(JumpPlatform, "width", setWidth, getWidth, xmlelement, mode);
73    }
74
75    /**
76    @brief
77        Is called every tick.
78        Handles the movement of the ball and its interaction with the boundaries and bats.
79    @param dt
80        The time since the last tick.
81    */
82    void JumpPlatform::tick(float dt)
83    {
84        SUPER(JumpPlatform, tick, dt);
85
86        Vector3 platformPosition = this->getPosition();
87
88        if (figure_ != nullptr)
89        {
90            Vector3 figurePosition = figure_->getPosition();
91            Vector3 figureVelocity = figure_->getVelocity();
92
93            float tolerance = 3.0;
94
95            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)
96            {
97                touchFigure();
98            }
99        }
100    }
101
102    void JumpPlatform::setFigure(JumpFigure* newFigure)
103    {
104        figure_ = newFigure;
105    }
106
107    void JumpPlatform::touchFigure()
108    {
109
110    }
111}
Note: See TracBrowser for help on using the repository browser.