My Code And Game So Far

// 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
    {
        if (Input == HiddenWord)
        {
            PrintLine(TEXT("You've Won"));
            EndGame();
        }
    
        else
        {
            if (Input.Len() != HiddenWord.Len())
            {
                PrintLine(TEXT("The HiddenWord has %i letters, Wrong Answer"), HiddenWord.Len());
            }
        }
    }
    


    
    /*
    Check If Isogram
    Prompt To Guess Again
    Check If Correct Number Of Characters
    Prompt To Guess Again
    Remove Life
    Check If Lives > 0
    If Yes Get Another Guess
    Show Lives Left
    If No ShowGameOver & HiddenWord
    Prompt To PlayAgain
    Check User Input
    PlayAgain Or Quit  
    */
}

void UBullCowCartridge::SetupGame()
{
    // Welcoming The Player
    PrintLine(TEXT("Good Mooooooring!! Welcome To Bulls & Cows"));

    HiddenWord = TEXT("cakes");
    Lives = 4;
    bGameOver = false;

    PrintLine(TEXT("Enter The %i Letter Word"), HiddenWord.Len());
    PrintLine(TEXT("Take A Guess & Press Enter To Continue...")); // Ask Player For Guess
}

void UBullCowCartridge::EndGame()
{
    bGameOver = true;
    PrintLine(TEXT("Press Enter To Play Again."));
}


1 Like

Great. Looks like you’re making good progress.

1 Like

Congrats Mate!!

1 Like

Privacy & Terms