Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pCuts/src/modules/tetris/TetrisCenterpoint.cc @ 9090

Last change on this file since 9090 was 9082, checked in by jo, 13 years ago

Trying to create tetris bricks. Rough implementation done. Still having a nasty camera bug. (see the debug output concerning the cameraIndex)

  • Property svn:eol-style set to native
File size: 3.2 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->brickTemplate_ = "";
58        this->stoneSpeed_ = 20.0f;
59       
60        this->checkGametype();
61    }
62
63    /**
64    @brief
65        Method to create a TetrisCenterpoint through XML.
66    */
67    void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
68    {
69        SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
70
71        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
72        XMLPortParam(TetrisCenterpoint, "height", setHeight, getHeight, xmlelement, mode); // die Grösse //was sollte das mit setWidth??
73        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
74        XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
75        XMLPortParam(TetrisCenterpoint, "brickTemplate", setBrickTemplate, getBrickTemplate, xmlelement, mode);
76        XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
77    }
78
79    /**
80    @brief
81        Is called when the gametype has changed.
82    */
83    void TetrisCenterpoint::changedGametype()
84    {
85        SUPER(TetrisCenterpoint, changedGametype);
86
87        // Check, whether it's still Tetris.
88        this->checkGametype();
89    }
90
91    /**
92    @brief
93        Checks whether the gametype is Tetris and if it is, sets its centerpoint.
94    */
95    void TetrisCenterpoint::checkGametype()
96    {
97        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
98        {
99            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
100            tetrisGametype->setCenterpoint(this);
101        }
102    }
103}
Note: See TracBrowser for help on using the repository browser.