This is my Code I checked everything according to the lecture but I am not getting the same result in the game as it is shown in the lecture i.e. when after every right and wrong answer the screen is not cleared. when I win the and as the code suggest that I have to press enter to play again and when presses it directly takes me to the output of wrong guess as shown in the screenshot I uploaded.
Image 1. After correct guess
Image 2.When enter is presses after the correct guess //directly the output of wrong guess
Please help me with this
// 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 Hidden Word is: %s. "), *HiddenWord); // Debug Line
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
if (bGameOver)
{
ClearScreen();
SetupGame();
}
else // Checking PlayerGuess
{
}
PrintLine(Input);
if (Input == HiddenWord)
{
PrintLine(TEXT("Congratulations! You Win."));
EndGame();
}
else
{
if (Input.Len() != 4 )
{
PrintLine(TEXT("There are only %i characters in the Hidden Word.\nYou have Lost!"), HiddenWord.Len());
EndGame();
}
}
}
// Check if it is Isogram
// Prompt To Guess Again
// Check number of characters
// Prompt to Guess again
// Remove Life
// Check if lives > 0
// If yes TryAgain
// Show lives left
// If no GameOver and HiddenWord
// Promt To Play Again, Press Enter to Play Again?
// Check User Input
// TryAgain or Quit
void UBullCowCartridge::SetupGame()
{
// Welcoming the Player
PrintLine(TEXT("Hello Kids! Welcome to the Bull Cows game."));
HiddenWord = TEXT("Adesh");
Lives = 3;
bGameOver = false;
PrintLine(TEXT("Guess the %i letter word!"), HiddenWord.Len());
PrintLine(TEXT("Type your answer and Press Enter.."));
}
void UBullCowCartridge::EndGame()
{
bGameOver = true;
PrintLine(TEXT("Press Enter to Play Again.."));
}