Working on the sleep

This commit is contained in:
Justin 2025-05-10 21:30:10 -05:00
parent 2a29f0dceb
commit f5b2925bdf
7 changed files with 29 additions and 17 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ ShotGun-Pete
banner.txt
print.d
intro.d
sleep.d

View File

@ -1,23 +1,14 @@
#include <iostream>
#include <thread>
#include "print.h"
#include "sleep.h"
using namespace std;
class Intro {
public:
Intro();
Intro(Intro &&) = default;
Intro(const Intro &) = default;
Intro &operator=(Intro &&) = default;
Intro &operator=(const Intro &) = default;
~Intro();
void intro();
void mainIntro();
private:
};
Intro::Intro() {
}
Intro::~Intro() {
}

View File

@ -1,2 +1,4 @@
#include <iostream>
#include "intro.h"
#include "title.h"
using namespace std;

8
src/include/sleep.h Normal file
View File

@ -0,0 +1,8 @@
#include <chrono>
using namespace std;
class Sleep{
public:
void delay(int milliseconds);
};

View File

@ -1,7 +1,6 @@
#include "include/intro.h"
void Intro::intro(){
Print print;
print.println("");
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));
}

View File

@ -1,8 +1,9 @@
#include "include/main.h"
#include "include/title.h"
int main (){
Title title;
title.mainTitle();
Intro intro;
intro.mainIntro();
return 0;
}

10
src/sleep.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "include/sleep.h"
void Sleep::delay(int milliseconds){
auto start = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::milliseconds(milliseconds);
while (std::chrono::high_resolution_clock::now() - start < duration) {
// Do nothing, just wait
}
}