From 657b97c4a830109e61c57f058efee63cbdf8aea3 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 10 May 2025 22:48:06 -0500 Subject: [PATCH] Working on the typing output. --- src/include/sleep.h | 7 ++++++- src/intro.cpp | 7 +++++-- src/sleep.cpp | 15 +++++++++++++++ src/title.cpp | 28 ++++++++++++++-------------- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/include/sleep.h b/src/include/sleep.h index 5364b60..dceb881 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -1,8 +1,13 @@ #include +#include +#include +#include +#include + using namespace std; class Sleep{ public: void delay(int milliseconds); - + void type(string text); }; diff --git a/src/intro.cpp b/src/intro.cpp index 6a5724f..af7a408 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -1,6 +1,9 @@ #include "include/intro.h" void Intro::mainIntro(){ - cout << "The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against steel shutters." << endl; - std::this_thread::sleep_for(std::chrono::milliseconds(3000)); + Sleep sleep; + int time = 2000; + sleep.delay(time); + sleep.type("The world didn't end with a bang. It ended with a groan.. and the scratching of death fingers against steel shutters."); + sleep.delay(time); } diff --git a/src/sleep.cpp b/src/sleep.cpp index e7acf29..ac16c8e 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -8,3 +8,18 @@ void Sleep::delay(int milliseconds){ // Do nothing, just wait } } +void Sleep::type(string text){ + int a = text.size(); + char* charArray = new char[a+1]; + strcpy(charArray, text.c_str()); + int i = 0; + int time = 300; + + while(i < a+1){ + std::this_thread::sleep_for(std::chrono::milliseconds(time)); + cout << charArray[i] << flush; + i++; + } + cout << endl; + delete[] charArray; +} diff --git a/src/title.cpp b/src/title.cpp index 7121074..bcabf89 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -1,21 +1,21 @@ #include "include/title.h" #include "include/print.h" - +#include "include/sleep.h" void Title::mainTitle(){ - int s = 2000; - Print print; - print.println("███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗"); - usleep(s); - print.println("██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝"); - usleep(s); - print.println("███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ "); - usleep(s); - print.println("╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ "); - usleep(s); - print.println("███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗"); - usleep(s); - print.println("╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝"); + Sleep sleep; + int time = 700; + cout << "███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗" << endl; + sleep.delay(time); + cout << "██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝" << endl; + sleep.delay(time); + cout << "███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ " << endl; + sleep.delay(time); + cout << "╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ " << endl; + sleep.delay(time); + cout << "███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗" << endl; + sleep.delay(time); + cout << "╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝" << endl; }