Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/tetris/TetrisBrick.h @ 9789

Last change on this file since 9789 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

File size: 3.5 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 TetrisBrick.h
31    @brief Declaration of the TetrisBrick class.
32    @ingroup Tetris
33*/
34
35#ifndef _TetrisBrick_H__
36#define _TetrisBrick_H__
37
38#include "tetris/TetrisPrereqs.h"
39
40#include "worldentities/ControllableEntity.h"
41#include "tools/Timer.h"
42
43namespace orxonox
44{
45
46    /**
47    @brief
48        ContainerClass in order to create TetrisBricks by combining TetrisStones.
49    @author
50
51    @ingroup Tetris
52    */
53    class _TetrisExport TetrisBrick : public ControllableEntity
54    {
55        public:
56            TetrisBrick(Context* context); //!< Constructor. Registers and initializes the object.
57            virtual ~TetrisBrick() {}
58
59            virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
60            virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
61            virtual void changedPlayer(); //!< Is called when the player changed.
62
63            bool isValidMove(const Vector3& position, bool isRotation);
64            unsigned int getNumberOfStones(void) const
65                { return this->brickStones_.size(); }
66            TetrisStone* getStone(unsigned int i);
67
68            void setGame(Tetris* tetris)
69                { assert(tetris); tetris_ = tetris; }
70            unsigned int getRotationCount(void)
71                { return this->rotationCount_;}
72
73            void releaseStones(TetrisCenterpoint* center);
74
75        protected:
76            void createBrick(void); //!< Create a cluster of TetrisStones
77            void formBrick(TetrisStone* stone, unsigned int i);
78            Tetris* getTetris();
79
80            unsigned int shapeIndex_; //!< My way to represent the different brick shapes.
81            unsigned int stonesPerBrick_; //!< So many stones are contained in this brick.
82            std::vector<TetrisStone*> brickStones_; //!< A list of all stones in a brick.
83
84
85            void enableMovement(void)
86                { this->delay_ = false; }
87            void unlockRotation(void)
88                { this->lockRotation_ = false; }
89
90            float getSize(void) const
91                { return this->size_; }
92
93
94            float size_; //!< The dimensions a stone has in the game world. //TODO: get stone dimensions
95            bool delay_;
96            bool lockRotation_;
97
98            unsigned int rotationCount_; //!< Stores the bricks orientation
99            Timer delayTimer_;
100            Timer rotationTimer_; ///!< This timer is used to filter out multiple rotation inputs.
101            Tetris* tetris_; //<! The Tetris class is responsible to initialize this value.
102
103    };
104}
105
106#endif /* _TetrisBrick_H__ */
Note: See TracBrowser for help on using the repository browser.