Working on the typing output.

This commit is contained in:
Justin 2025-05-10 22:48:06 -05:00
parent f5b2925bdf
commit 657b97c4a8
4 changed files with 40 additions and 17 deletions

View File

@ -1,8 +1,13 @@
#include <chrono> #include <chrono>
#include <string>
#include <iostream>
#include <cstring>
#include <thread>
using namespace std; using namespace std;
class Sleep{ class Sleep{
public: public:
void delay(int milliseconds); void delay(int milliseconds);
void type(string text);
}; };

View File

@ -1,6 +1,9 @@
#include "include/intro.h" #include "include/intro.h"
void Intro::mainIntro(){ 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; Sleep sleep;
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 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);
} }

View File

@ -8,3 +8,18 @@ void Sleep::delay(int milliseconds){
// Do nothing, just wait // 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;
}

View File

@ -1,21 +1,21 @@
#include "include/title.h" #include "include/title.h"
#include "include/print.h" #include "include/print.h"
#include "include/sleep.h"
void Title::mainTitle(){ void Title::mainTitle(){
int s = 2000; Sleep sleep;
Print print; int time = 700;
print.println("███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗"); cout << "███████╗██╗ ██╗ ██████╗ ████████╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ███████╗████████╗███████╗" << endl;
usleep(s); sleep.delay(time);
print.println("██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝"); cout << "██╔════╝██║ ██║██╔═══██╗╚══██╔══╝██╔════╝ ██║ ██║████╗ ██║ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝" << endl;
usleep(s); sleep.delay(time);
print.println("███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ "); cout << "███████╗███████║██║ ██║ ██║ ██║ ███╗██║ ██║██╔██╗ ██║ ██████╔╝█████╗ ██║ █████╗ " << endl;
usleep(s); sleep.delay(time);
print.println("╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ "); cout << "╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔═══╝ ██╔══╝ ██║ ██╔══╝ " << endl;
usleep(s); sleep.delay(time);
print.println("███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗"); cout << "███████║██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ███████╗ ██║ ███████╗" << endl;
usleep(s); sleep.delay(time);
print.println("╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝"); cout << "╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝" << endl;
} }