[Orxonox-commit 4410] r9081 - in code/branches/pCuts/src/modules: pong tetris
jo at orxonox.net
jo at orxonox.net
Thu Apr 5 11:12:08 CEST 2012
Author: jo
Date: 2012-04-05 11:12:08 +0200 (Thu, 05 Apr 2012)
New Revision: 9081
Modified:
code/branches/pCuts/src/modules/pong/Pong.cc
code/branches/pCuts/src/modules/tetris/TetrisStone.cc
code/branches/pCuts/src/modules/tetris/TetrisStone.h
Log:
Added rotation to the TetrisStones.
Modified: code/branches/pCuts/src/modules/pong/Pong.cc
===================================================================
--- code/branches/pCuts/src/modules/pong/Pong.cc 2012-04-03 07:09:07 UTC (rev 9080)
+++ code/branches/pCuts/src/modules/pong/Pong.cc 2012-04-05 09:12:08 UTC (rev 9081)
@@ -283,7 +283,7 @@
}
// If a palyer gets 21 points, he won the game -> end of game
-
+
PlayerInfo* player1 = this->getLeftPlayer();
PlayerInfo* player2 = this->getRightPlayer();
if(player1==NULL||player2==NULL) return; //safety
Modified: code/branches/pCuts/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/branches/pCuts/src/modules/tetris/TetrisStone.cc 2012-04-03 07:09:07 UTC (rev 9080)
+++ code/branches/pCuts/src/modules/tetris/TetrisStone.cc 2012-04-05 09:12:08 UTC (rev 9081)
@@ -36,6 +36,8 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include <OgreSceneNode.h>
+
#include "Tetris.h"
namespace orxonox
@@ -46,13 +48,15 @@
@brief
Constructor. Registers and initializes the object.
*/
- TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
+ TetrisStone::TetrisStone(BaseObject* creator) : Pawn(creator)
{
RegisterObject(TetrisStone);
-
+
this->size_ = 10.0f;
this->delay_ = false;
this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
+ this->lockRotation_ = false;
+
}
/**
@@ -63,10 +67,19 @@
*/
void TetrisStone::moveFrontBack(const Vector2& value)
{
- if(value.x < 0)
+ if(value.x < 0) //speedup on key down
{
this->setVelocity(this->getVelocity()*1.1);
}
+ else if(!this->lockRotation_) //rotate when key up is pressed
+ {
+ orxout() << "The object should be rolled soon." << endl;
+ this->lockRotation_ = true; // multiple calls of this function have to be filtered out.
+ this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisStone::unlockRotation, this)));
+ Quaternion q(Degree(90), Vector3::UNIT_Z);
+ this->setOrientation(this->getOrientation()*q); //rotation: roll 90°
+
+ }
}
/**
Modified: code/branches/pCuts/src/modules/tetris/TetrisStone.h
===================================================================
--- code/branches/pCuts/src/modules/tetris/TetrisStone.h 2012-04-03 07:09:07 UTC (rev 9080)
+++ code/branches/pCuts/src/modules/tetris/TetrisStone.h 2012-04-05 09:12:08 UTC (rev 9081)
@@ -37,7 +37,7 @@
#include "tetris/TetrisPrereqs.h"
-#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
#include "tools/Timer.h"
namespace orxonox
@@ -50,7 +50,7 @@
@ingroup Tetris
*/
- class _TetrisExport TetrisStone : public ControllableEntity
+ class _TetrisExport TetrisStone : public Pawn
{
public:
TetrisStone(BaseObject* creator); //!< Constructor. Registers and initializes the object.
@@ -80,10 +80,14 @@
private:
void enableMovement(void)
{ this->delay_ = false; }
-
+ void unlockRotation(void)
+ { this->lockRotation_ = false; }
+
float size_; //!< The dimensions a stone has in the game world.
bool delay_;
+ bool lockRotation_;
Timer delayTimer_;
+ Timer rotationTimer_;
Tetris* tetris_;
};
More information about the Orxonox-commit
mailing list