void SceneGraphDeviceContext::MoveTextTo(int x, int y, vrv::data_HORIZONTALALIGNMENT alignment)
{
    Q_ASSERT(m_currentTextQuickItem != nullptr);

    // If the current text item already has some text, we have to create a new one which automatically sets the position
    // and alignment. If no alignment is specified, we use the alignment of the current text item.
    if (!m_currentTextQuickItem->isEmpty()) {
        if (alignment == vrv::HORIZONTALALIGNMENT_NONE) {
            switch (m_currentTextQuickItem->getAlignment()) {
                case Qt::AlignLeft: alignment = vrv::HORIZONTALALIGNMENT_left; break;
                case Qt::AlignRight: alignment = vrv::HORIZONTALALIGNMENT_right; break;
                case Qt::AlignHCenter: alignment = vrv::HORIZONTALALIGNMENT_center; break;
                case Qt::AlignJustify: alignment = vrv::HORIZONTALALIGNMENT_justify; break;
            }
        }
        EndText();
        StartText(x, y, alignment);
        return;
    }
    else {
        SetTextPositionAndAlignment(x, y, alignment);
    }
}
Example #2
0
/*******************************************************************************************************
* GANE ENGINE - handles the looping of the game
*******************************************************************************************************/
void GameEngine()
{
	// user input variables
	const int userInputLimit = 11;
	char userInput[userInputLimit] = {};
	bool humanFinished = false;
	bool moveHuman = false;
	StringOO humanMove = "move south";
	int loopCount = 0;

	// location variables
	const int locationNum = 11;
	Location *Locations[locationNum] = {};
	int prevLocation = 0;
	int newLocation = 0;
	int finishLocation = locationNum - 1;

	// human player variables
	int humanLoc = 0;
	StringOO name = "Bruce";
	int strength = 10;
	int health = 100;
	int luck = 10;
	int intellegence = 10;

	// enemy variables
	const int enemyNum = 5;
	Enemy * Enemies[enemyNum] = {};

	// challenges variables
	const int challengeNum = 16;
	Challenge *Challenges[challengeNum] = {};

	// initialise Locations
	InitLocations(Locations);

	// initialise human
	Human Human(humanLoc, name, strength, health, luck, intellegence);

	// initialise Enemies
	InitEnemies(Enemies, enemyNum);

	// initialise Challenges
	InitChallenges(Challenges);
	//AllocateChallenges(Locations, locationNum);
	AllocateChallengesManually(Locations, locationNum);
	AddEnemyToChallenge(Challenges, enemyNum, challengeNum);

	// initial splash screen
	SetConsole();
	StartText(Human);

	// Game loop
	while (!humanFinished)
	{
		// print out details of room
		std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl;
		while (!moveHuman)
		{
			// get user to enter move
			std::cout << "+ ";
			std::cin.getline(userInput, userInputLimit);
			std::cout << std::endl;
			humanMove = userInput;
			if (loopCount == 5)
			{
				std::cout << "\n     ENOUGH ALREADY...YOUR MOVING SOUTH!! \n\n";
				//bored of guesses
				humanMove = "move south";
				loopCount = 0;
			}
			// determine the new location
			newLocation = PlayerMove(Human, humanMove, Locations[Human.GetLocation()]->GetAjacentLoc());

			// validate users move and if validate change their location
			if (ValidateMove(newLocation, prevLocation))
			{
				// set challenge user has to perform before progrogressing to the next room
				Human.SetChallenge(Locations[Human.GetLocation()]->GetPathChallenge(Human.GetHeading()));
				// challenge User
				Challenge *ChallengePtr = Challenges[Human.GetChallenge()];
				ApplyChallenge(ChallengePtr, Human, Enemies);
				// move user to new location
				prevLocation = Human.GetLocation();
				Human.SetPrevHeading(Human.GetHeading());
				Human.SetLocation(newLocation);
				moveHuman = true;
				loopCount = 0;
				std::cout << "\n***----------------------------*  pop!  *-------------------------------------**\n\n";
			}
			else
			{
				// invalid move try again
				moveHuman = false;
				loopCount++;
			}
		}
		// reset move
		moveHuman = false;
		//check if user is in the finish location
		if (Human.GetLocation() == finishLocation)
		{
			humanFinished = true;
			std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl;
			FinishText(Human);
		}

	}
	//DestroyEnemies(Enemies, enemyNum);
	for (int i = 0; i < enemyNum; i++)
	{
		delete Enemies[i];
	}
	//DestroyChallenges(Challenges, challengeNum);
	for (int i = 0; i < challengeNum; i++)
	{
		delete Challenges[i];
	}
	//DestroyLocations(Locations, locationNum);
	for (int i = 0; i < locationNum; i++)
	{
		delete Locations[i];
	}

}