| [8249] | 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 | |
|---|
| [8537] | 39 | #include "Tetris.h" |
|---|
| 40 | |
|---|
| [8249] | 41 | namespace 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 | { |
|---|
| [8563] | 66 | if(value.x < 0) |
|---|
| 67 | { |
|---|
| 68 | this->setVelocity(this->getVelocity()*1.1); |
|---|
| 69 | } |
|---|
| [8249] | 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(); |
|---|
| [8537] | 83 | Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z); |
|---|
| [8566] | 84 | if(!this->tetris_->isValidMove(this, newPos)) |
|---|
| [8537] | 85 | return; |
|---|
| 86 | |
|---|
| 87 | this->setPosition(newPos); |
|---|
| [8249] | 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 | } |
|---|