Intro for Bulls and Cows

Hello fellow coders.

I have just finished Secrion 2 of the Unreal course and decided that before i go on and dive into Unreal i want to modify the Bulls and Cows game a little bit. Yesterday i started working on an Intro for it and wanted to ask you for feedback. I am still experimenting with the ASCII art and the arrangement of the letters. Tomorrow i can provide you the code snippets for the “animation” and the colouring. As to day it will only work on Windows. So feel free to comment and have fun whatching it.

Sry for the late addition but i had to do a little rework of the code.
I will block this comment in 2 sections. The first one is for the typewriter effect and the second one is for the coloring.

So the typewriter effect:
Here are the includes and the function for it.


#include <thread>
#include <chrono>

//function declaration
void TypeWriter(const FText, unsigned int);


//function definition
void TypeWriter(const FText intro, unsigned int MilisecondsPerChar)
{
	for (const auto c : intro)
	{
		std::cout << c << std::flush;
		std::this_thread::sleep_for(std::chrono::milliseconds(MilisecondsPerChar));
	}
}

now for the coloring


#include <Windows.h>

HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(hConsole, 4); //will set the text to red. play with the value to get other colors. 7 will get it back to black and white.

That looks awesome!
I’m not quite there with the typewriter effect but the text change in colour is something I think I might steal to help illustrate errors and if there are bulls or cows!

Thanks!

Sam

Privacy & Terms