Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8537 was 8537, checked in by catherine, 13 years ago

Almost working.

File size: 2.8 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        this->previousPosition_ = Vector3::ZERO;
57    }
58
59    void TetrisStone::tick(float dt)
60    {
61        SUPER(TetrisStone, tick, dt);
62    }
63
64    /**
65    @brief
66        Overloaded the function to rotate the stone.
67    @param value
68        A vector whose first component is the angle by which to rotate.
69    */
70    void TetrisStone::moveFrontBack(const Vector2& value)
71    {
72       
73    }
74
75    /**
76    @brief
77        Overloaded the function to steer the stone right and left
78    @param value
79        A vector whose first component is the direction in which we want to steer the stone.
80    */
81    void TetrisStone::moveRightLeft(const Vector2& value)
82    {
83        if(!this->delay_)
84        {
85            const Vector3& position = this->getPosition();
86            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
87            if(!this->tetris_->isValidMove(this, newPos))
88                return;
89
90            //this->previousPosition_ = position;
91            this->setPosition(newPos);
92            this->delay_ = true;
93            this->delayTimer_.startTimer();
94        }
95    }
96
97    /**
98    @brief
99        Is called when the player changed.
100    */
101    void TetrisStone::changedPlayer()
102    {
103        this->setVelocity(0, 0, 0);
104    }
105}
Note: See TracBrowser for help on using the repository browser.