Hi there!
Been using the Questions Section over at Udemy to show off the work I’ve done along the course and will be using this thread in order to keep a record on the stuff I do. Feedback will be gladly appreciated, and thank you for stopping by
Currently on Section 3: Coding the basic Game Loop
This is what my code looks like:
BullCowCartridge.h
#include "BullCowCartridge.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
PrintLine(TEXT("Welcome to the Bulls & Cows guessing game!"));
PrintLine(TEXT("Press TAB to access the terminal."));
PrintLine(TEXT("Guess the word and press ENTER to see if you were right!"));
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
ClearScreen();
FString HiddenWord = TEXT("Tongue");
PrintLine(Input);
if (Input == HiddenWord)
{
PrintLine(TEXT("You got the word!"));
}
else
{
PrintLine(TEXT("Wrong word!"));
}
}
As said in the course video, we are initializing the code each time we press enter, so we need to move it to BeginPlay() or store it somewhere else so we can change it after playing the game, and also needs to be readable inside the OnInput() function.