Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Added rotation to the TetrisStones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.