Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/modules/tetris/TetrisStone.cc @ 8974

Last change on this file since 8974 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: 2.7 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 TetrisStone.cc
31    @brief Implementation of the TetrisStone class.
32*/
33
34#include "TetrisStone.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38
39#include "Tetris.h"
40
41namespace orxonox
42{
43    CreateFactory(TetrisStone);
44
45    /**
46    @brief
47        Constructor. Registers and initializes the object.
48    */
49    TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
50    {
51        RegisterObject(TetrisStone);
52       
53        this->size_ = 10.0f;
54        this->delay_ = false;
55        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
56    }
57
58    /**
59    @brief
60        Overloaded the function to rotate the stone.
61    @param value
62        A vector whose first component is the angle by which to rotate.
63    */
64    void TetrisStone::moveFrontBack(const Vector2& value)
65    {
66        if(value.x < 0)
67        {
68            this->setVelocity(this->getVelocity()*1.1);
69        }
70    }
71
72    /**
73    @brief
74        Overloaded the function to steer the stone right and left
75    @param value
76        A vector whose first component is the direction in which we want to steer the stone.
77    */
78    void TetrisStone::moveRightLeft(const Vector2& value)
79    {
80        if(!this->delay_)
81        {
82            const Vector3& position = this->getPosition();
83            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
84            if(!this->tetris_->isValidMove(this, newPos))
85                return;
86
87            this->setPosition(newPos);
88            this->delay_ = true;
89            this->delayTimer_.startTimer();
90        }
91    }
92
93    /**
94    @brief
95        Is called when the player changed.
96    */
97    void TetrisStone::changedPlayer()
98    {
99        this->setVelocity(0, 0, 0);
100    }
101}
Note: See TracBrowser for help on using the repository browser.