I have some code and it’s showing no errors in IntelliSense but I have the following errors while compiling it in unreal:
Also, here’s my 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((FString::Printf(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{
ProcessGuess(Input, Lives);
}
/*
Is isogram?
Right # of chars?
Remove Life
Check if life < 0
if true end game and promt restart
if false then show them ammount of lives left and let them try again
*/
}
void UBullCowCartridge::SetupGame(){
HiddenWord = "cake";
Lives = HiddenWord.Len();
bGameOver = false;
PrintLine(FString::Printf(TEXT("Welcome to Bulls Cows!\nYou have %i lives.\nGuess the %i letter word and press enter to\ncontinue..."), Lives, HiddenWord.Len()));
}
void UBullCowCartridge::EndGame(){
bGameOver = true;
PrintLine(TEXT("Press enter to play again"));
}
void UBullCowCartridge::ProcessGuess(FString Guess, int32 Lives){
//if (!IsIsogram) {
// PrintLine(TEXT("There are no repeating letters"));
//}
// Check if the guess and the hidden word are the same
if(Guess == HiddenWord){
PrintLine(TEXT("You win!"));
EndGame();
return;
}
if (Guess.Len() != HiddenWord.Len()) {
PrintLine(FString::Printf(TEXT("You're wrong! The word has %i letters"), HiddenWord.Len()));
return;
}
PrintLine(FString::Printf(TEXT("You have lost a life")));
PrintLine(FString::Printf(TEXT("You have %i lives left"), --Lives));
// Check if the length of the hidden word and the length of the guess are the same
if (Lives <= 0) {
PrintLine("You have ran out of lives");
EndGame();
return;
}
PrintLine(FString::Printf(TEXT("You Guess again. You have %i lives left"), Lives));
ClearScreen();
PrintLine(FString::Printf(TEXT("The hidden word was %s."), HiddenWord));
//else{
// if(Guess.Len() != HiddenWord.Len()){
// PrintLine(FString::Printf(TEXT("You're wrong! The word has %i letters"), HiddenWord.Len()));
// }else{
// PrintLine(TEXT("You're wrong!"));
// --Lives;
// PrintLine(TEXT("You have lost a life."));
// if(Lives <= 0){
// PrintLine("You have ran out of lives");
// EndGame();
// }else{
// PrintLine(FString::Printf(TEXT("You have %i lives left."), Lives));
// }
// }
//}
}
