-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloading.cpp
43 lines (33 loc) · 1.07 KB
/
loading.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <chrono>
#include <thread>
int main() {
int animationDelay = 100; // Delay between each frame in milliseconds
int numFrames = 10; // Number of frames in the animation
for (int i = 0; i <= numFrames; i++) {
// Clear the screen
system("cls");
// Display the loading text
std::cout << "Loading...\n";
// Display the loading animation
std::cout << "[";
for (int j = 0; j < i; j++) {
std::cout << "=";
}
std::cout << ">";
for (int j = i; j < numFrames; j++) {
std::cout << "-";
}
std::cout << "]\n";
// Display the percentage
int percentage = (i * 100) / numFrames;
std::cout << percentage << "%\n";
// Sleep for the specified delay
std::this_thread::sleep_for(std::chrono::milliseconds(animationDelay));
}
// Clear the screen after the animation is complete
system("cls");
// Display a completion message
std::cout << "Loading complete!" << std::endl;
return 0;
}