Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/3DPacman_FS18/src/modules/tetris/TetrisCenterpoint.cc @ 12073

Last change on this file since 12073 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.0 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 *      ...
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file TetrisCenterpoint.cc
31    @brief Implementation of the TetrisCenterpoint class.
32    @ingroup Tetris
33*/
34
35#include "TetrisCenterpoint.h"
36
37#include "core/CoreIncludes.h"
38#include "core/XMLPort.h"
39
40#include "Tetris.h"
41
42namespace orxonox
43{
44    RegisterClass(TetrisCenterpoint);
45
46    /**
47    @brief
48        Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
49    */
50    TetrisCenterpoint::TetrisCenterpoint(Context* context) : StaticEntity(context)
51    {
52        RegisterObject(TetrisCenterpoint);
53
54        this->width_ = 10;
55        this->height_ = 11;
56        this->stoneSize_ = 10.0f;
57        this->stoneTemplate_ = "";
58        this->brickTemplate_ = "";
59        this->stoneSpeed_ = 20.0f;
60       
61        this->checkGametype();
62    }
63
64    /**
65    @brief
66        Method to create a TetrisCenterpoint through XML.
67    */
68    void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
69    {
70        SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
71
72        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
73        XMLPortParam(TetrisCenterpoint, "height", setHeight, getHeight, xmlelement, mode); // die Grösse //was sollte das mit setWidth??
74        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
75        XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
76        XMLPortParam(TetrisCenterpoint, "brickTemplate", setBrickTemplate, getBrickTemplate, xmlelement, mode);
77        XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
78    }
79
80    /**
81    @brief
82        Checks whether the gametype is Tetris and if it is, sets its centerpoint.
83    */
84    void TetrisCenterpoint::checkGametype()
85    {
86        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Tetris)))
87        {
88            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
89            tetrisGametype->setCenterpoint(this);
90        }
91    }
92}
Note: See TracBrowser for help on using the repository browser.