Exemple #1
0
KJumpingCube::KJumpingCube()
  : view(new KCubeBoxWidget(5, this, "KCubeBoxWidget"))
{
   connect(view,SIGNAL(playerChanged(int)),SLOT(changePlayer(int)));
   connect(view,SIGNAL(stoppedMoving()),SLOT(disableStop()));
   connect(view,SIGNAL(stoppedThinking()),SLOT(disableStop()));
   connect(view,SIGNAL(startedMoving()),SLOT(enableStop_Moving()));
   connect(view,SIGNAL(startedThinking()),SLOT(enableStop_Thinking()));
   connect(view,SIGNAL(playerWon(int)),SLOT(showWinner(int)));

   // tell the KMainWindow that this is indeed the main widget
   setCentralWidget(view);

   // init statusbar
   QString s = i18n("Current player:");
   statusBar()->insertItem(s,ID_STATUS_TURN_TEXT, false);
   statusBar()->changeItem(s,ID_STATUS_TURN_TEXT);
   statusBar()->setItemAlignment (ID_STATUS_TURN_TEXT, AlignLeft | AlignVCenter);
   statusBar()->setFixedHeight( statusBar()->sizeHint().height() );
 
   currentPlayer = new QWidget(this, "currentPlayer");
   currentPlayer->setFixedWidth(40);
   statusBar()->addWidget(currentPlayer, ID_STATUS_TURN, false);
   statusBar()->setItemAlignment(ID_STATUS_TURN, AlignLeft | AlignVCenter);

   initKAction();
   changePlayer(1);
}
void CharacterMovement::moveTo()
{
	qDebug() << "[CharacterMovement::moveTo]";
	// Get current position
	_position = UtilFunctions::ogreVector3ToQVector3d( _node->getPosition() );

	// clear the list of point
//	_moveList.clear();

	// Compute distance to new location
	_distance = UtilFunctions::calculateDistance( _position, _destination );
	qDebug() << "[CharacterMovement::moveTo] - Distance:" << _distance << "Pos:" << _position << "Dest:" << _destination;
	if( _distance > 0.000001f )
	{
		// compute direction vector
		_direction = _destination - _position;
		_direction.normalize();
		_moving = true;
		rotateTo(_destination);
		qDebug() << "[CharacterMovement::moveTo] - Emited startedMoving";
		emit startedMoving();
	}
}