Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/animated_space_boundaries/src/modules/tetris/TetrisCenterpoint.cc @ 11112

Last change on this file since 11112 was 8645, checked in by landauf, 13 years ago

set svn:eol-style to native, removed svn:executable property. no code changes.

  • 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*/
33
34#include "TetrisCenterpoint.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38
39#include "Tetris.h"
40
41namespace orxonox
42{
43    CreateFactory(TetrisCenterpoint);
44
45    /**
46    @brief
47        Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
48    */
49    TetrisCenterpoint::TetrisCenterpoint(BaseObject* creator) : StaticEntity(creator)
50    {
51        RegisterObject(TetrisCenterpoint);
52
53        this->width_ = 10;
54        this->height_ = 11;
55        this->stoneSize_ = 10.0f;
56        this->stoneTemplate_ = "";
57        this->stoneSpeed_ = 20.0f;
58       
59        this->checkGametype();
60    }
61
62    /**
63    @brief
64        Method to create a TetrisCenterpoint through XML.
65    */
66    void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
67    {
68        SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
69
70        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
71        XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
72        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
73        XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
74        XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
75    }
76
77    /**
78    @brief
79        Is called when the gametype has changed.
80    */
81    void TetrisCenterpoint::changedGametype()
82    {
83        SUPER(TetrisCenterpoint, changedGametype);
84
85        // Check, whether it's still Tetris.
86        this->checkGametype();
87    }
88
89    /**
90    @brief
91        Checks whether the gametype is Tetris and if it is, sets its centerpoint.
92    */
93    void TetrisCenterpoint::checkGametype()
94    {
95        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
96        {
97            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
98            tetrisGametype->setCenterpoint(this);
99        }
100    }
101}
Note: See TracBrowser for help on using the repository browser.