Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9081


Ignore:
Timestamp:
Apr 5, 2012, 11:12:08 AM (12 years ago)
Author:
jo
Message:

Added rotation to the TetrisStones.

Location:
code/branches/pCuts/src/modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pCuts/src/modules/pong/Pong.cc

    r9016 r9081  
    284284
    285285        // If a palyer gets 21 points, he won the game -> end of game
    286        
     286
    287287        PlayerInfo* player1 = this->getLeftPlayer();
    288288        PlayerInfo* player2 = this->getRightPlayer();
  • code/branches/pCuts/src/modules/tetris/TetrisStone.cc

    r8706 r9081  
    3737#include "core/XMLPort.h"
    3838
     39#include <OgreSceneNode.h>
     40
    3941#include "Tetris.h"
    4042
     
    4749        Constructor. Registers and initializes the object.
    4850    */
    49     TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
     51    TetrisStone::TetrisStone(BaseObject* creator) : Pawn(creator)
    5052    {
    5153        RegisterObject(TetrisStone);
    52        
     54
    5355        this->size_ = 10.0f;
    5456        this->delay_ = false;
    5557        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
     58        this->lockRotation_ = false;
     59
    5660    }
    5761
     
    6468    void TetrisStone::moveFrontBack(const Vector2& value)
    6569    {
    66         if(value.x < 0)
     70        if(value.x < 0) //speedup on key down
    6771        {
    6872            this->setVelocity(this->getVelocity()*1.1);
     73        }
     74        else if(!this->lockRotation_) //rotate when key up is pressed
     75        {
     76            orxout() << "The object should be rolled soon." << endl;
     77            this->lockRotation_ = true; // multiple calls of this function have to be filtered out.
     78            this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisStone::unlockRotation, this)));
     79            Quaternion q(Degree(90), Vector3::UNIT_Z);
     80            this->setOrientation(this->getOrientation()*q); //rotation: roll 90°
     81
    6982        }
    7083    }
  • code/branches/pCuts/src/modules/tetris/TetrisStone.h

    r8706 r9081  
    3838#include "tetris/TetrisPrereqs.h"
    3939
    40 #include "worldentities/ControllableEntity.h"
     40#include "worldentities/pawns/Pawn.h"
    4141#include "tools/Timer.h"
    4242
     
    5151    @ingroup Tetris
    5252    */
    53     class _TetrisExport TetrisStone : public ControllableEntity
     53    class _TetrisExport TetrisStone : public Pawn
    5454    {
    5555        public:
     
    8181            void enableMovement(void)
    8282                { this->delay_ = false; }
    83            
     83            void unlockRotation(void)
     84                { this->lockRotation_ = false; }
     85
    8486            float size_; //!< The dimensions a stone has in the game world.
    8587            bool delay_;
     88            bool lockRotation_;
    8689            Timer delayTimer_;
     90            Timer rotationTimer_;
    8791
    8892            Tetris* tetris_;
Note: See TracChangeset for help on using the changeset viewer.