Hi Guys,
Loving the course but am finding i am getting a little bit away from the curriculum. I have the code working as intended however it looks slightly different from the lecturer & has extra code in it (getting carried away with coding). Should i be sticking to how it is written in the lectures in case i struggle in a chapter or is it ok for me to keep going with how i have written it?
I have attached screen shot of lecturers code & pasted mine for reference. hoping someone can help i dont want to get too far away from curriculum & struggle to get back or have to rewrite code if needed.
// 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 Player Guess
{
if (Input == HiddenWord)
{
PrintLine(TEXT("Well done you have guessed \nthe Hidden Word!"));
EndGame();
}
else
{
if (Input.Len() != HiddenWord.Len())
{
PrintLine(TEXT("The Length is not correct. It is a %i \nLetter Word"), HiddenWord.Len());
}
else
{
PrintLine(TEXT("The length is correct but the answer is \nwrong"));
}
if (Lives > 0)
{
Lives--;
PrintLine(TEXT("You have lost a live, \nyou have %i lives left"), Lives);
}
else
{
PrintLine(TEXT("You have lost"));
EndGame();
}
}
}
//check Input for isogram
//check Input for NumChar
//check correct
//if Correct Win, Ask to PlayAgain
//If no remove life
//show NumLives left
//check NumLives > 0
//if NumLives > 0 "GuessAgain"
// if NumLives = 0 Lose and show HiddenWord, Ask to PlayAgain
//
}
void UBullCowCartridge::SetUpGame()
{
//Setting up Game Parameters
HiddenWord = (TEXT("cakes"));
Lives = HiddenWord.Len();
bGameOver = false;
// Welcome to Game
PrintLine(TEXT("Hello welcome to Bull Cow Game!!"));
PrintLine(TEXT("Guess the %i letter Isogram word"), HiddenWord.Len());
PrintLine(TEXT("You Have %i to guess the isogram"), Lives);
PrintLine(TEXT("Type in your guess and \npress enter to continue....."));
}
void UBullCowCartridge::EndGame()
{
{
bGameOver = true;
PrintLine(TEXT("Press enter to play again"));
}
}