Added a Hint System in the BullCow Game

Code only the hint() function:
void UBullCowCartridge::Hint(int32 &Liv)

{

FString Ht;

char *ptr = (char *)calloc(sizeof(char), Liv);

for (int i = 0; i < Liv - 2; i++)

{

    Characters = (HiddenWord[FMath::RandRange(0, Lives - 1)]);

    for (int j = 0; j < HiddenWord.Len(); j++)

    {

        if (Characters == HiddenWord[j])

        {

            ptr[j] = Characters;

            break;

        }

    }

}

for (int i = 0; i < HiddenWord.Len(); i++)

    if (ptr[i] == 0)

        Ht.AppendChar('_');

    else

        Ht.AppendChar(ptr[i]);

PrintLine(Ht);

}

*Tell me if I can Improve something.





2 Likes

The backdrop is amazing. The hint is a good modification too.

Thanks for sharing.

Thanks

Privacy & Terms