when I press play unreal stops responding
this is the code
// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
SetupGame();
PrintLine(TEXT("The hiddenWord is: %s."), *HiddenWord);
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
if(bGameOver)
{
ClearScreen();
SetupGame();
}
else
{
ProcessGuess(Input);
}
}
void UBullCowCartridge::SetupGame()
{
PrintLine(TEXT("Welcome to Bull Cows!"));
HiddenWord = TEXT("Cakes");
Lives = HiddenWord.Len();
bGameOver = false;
PrintLine(TEXT("Guess the %i letter word"), HiddenWord.Len());
PrintLine(TEXT("you have %i lives."), Lives);
PrintLine(TEXT("Type in your guess \n press enter to continue..."));
//const TCHAR HW[] = TEXT("plums");
//PrintLine(TEXT("Character 1 of the hiddenword is: %c"), HiddenWord[0]);
//PrintLine(TEXT("The 4th character of HW is: %c"), HW[3]);
int32 i =0;
while (i < 10)
{
PrintLine(TEXT("%i"), i);
}
for (int32 Index = 0; Index < 2; Index++)
{
PrintLine(TEXT("%i"), Index);
}
int32 j = 0;
do
{
PrintLine(TEXT("%i"), j);
} while (j < 2);
}
void UBullCowCartridge::EndGame()
{
bGameOver = true;
PrintLine(TEXT("\npress enter to play again."));
}
void UBullCowCartridge::ProcessGuess(FString Guess)
{
if (Guess == HiddenWord)
{
PrintLine(TEXT("you have won"));
EndGame();
return;
}
if (Guess.Len() != HiddenWord.Len())
{
PrintLine(TEXT("The hidden word is %i letters long"), HiddenWord.Len());
PrintLine(TEXT("Sorry, try guessing again \n You have %i lives remaining"), Lives);
return;
}
if (!IsIsogram(Guess))
{
PrintLine(TEXT("No repeating letters, guess again"));
return;
}
// remove life
PrintLine(TEXT("Lost a life"));
--Lives;
if (Lives <= 0)
{
ClearScreen();
PrintLine(TEXT("You have no lives left!"));
PrintLine(TEXT("the hidden word was: %s"), *HiddenWord);
EndGame();
return;
}
// show the player Bulls and Cows
PrintLine(TEXT("Guess again, you have %i lives left"), Lives);
}
bool UBullCowCartridge::IsIsogram(FString Word) const
{
return true;
}