Hello Guys,
That’s my implementation, when player come to the last lives console will print the first and then last letter of the hidden word.
Header file:
struct LastChance
{
TCHAR FirstLetter;
TCHAR LastLetter;
};
//other code....
public:
LastChance TipsLetter(const FString& Parola) const;
Call in cpp file:
if(Vite == 1)
{
LastChance LettereFinal = TipsLetter(ParolaSegreta);
PrintLine(TEXT("Ultima Vita, Suggerimento Finale!!\nLa parola inizia con: %c\nFinisce con:%c"), LettereFinal.FirstLetter,LettereFinal.LastLetter);
return;
}
Function:
LastChance UBullCowCartridge::TipsLetter(const FString& Parola) const
{
LastChance Letters;
for (int32 i = 0; i < Parola.Len(); i++)
{
if (i == 0)
{
Letters.FirstLetter = Parola[i];
}
if (i == Parola.Len() - 1)
{
Letters.LastLetter = Parola[i];
}
}
return Letters;
}
Is there a better or more performing way to achieve the same result or did I do a good job?
thanks a lot