Creating the first function

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"

void UBullCowCartridge::BeginPlay() // When the game 
{
    Super::BeginPlay();
	
	IntiateGame();

	/*	
		Welcome Message Instructions

		Intiate game (lives Levels hidden word)

		While (guess)
			
			Get input
			If (play)
				Display Win
				Level ++
			else	
				Display Bulls and Cows
				if(Life > 0)
					Life --
				else
					if(PlayAgain)
						Intiate new game
					else
						break
		Quit
				
	*/
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
	ClearScreen();
	PrintLine(Input);
	if (HiddenWord == Input) {
		PrintLine(TEXT("Y"));
	}
	else {
		PrintLine(TEXT("N"));
	}
}

void UBullCowCartridge::DisplayWelcomeMessage()
{
	PrintLine(TEXT("Velcro's Bulls and Cows"));
	PrintLine(TEXT("\nPlease click on board and press 'Tab' to start"));
	PrintLine(TEXT("\nEnter a " ) + FString::FromInt(GameLevel + 3) + TEXT(" letter word..."));
}

void UBullCowCartridge::IntiateGame()
{
	//Intiate game(lives Levels hidden word)
	GameLevel = 1;
	Lives = GameLevel * LivesMultiplier;
	HiddenWord = GetHiddenWord();
	if (isItDebugTime) { PrintLine(TEXT("\nThe Hidden word is:") + HiddenWord); }
	DisplayWelcomeMessage();
}

FString UBullCowCartridge::GetHiddenWord()
{
	HiddenWord = TEXT("asdf");
	return HiddenWord;
}



1 Like

Great first function!

1 Like

Privacy & Terms