Echos in The Dark
Echos in The Dark
#include <string>
#include <cstdlib>
#include <ctime>
// Function declarations
void intro();
void explore();
void infirmary();
void basement();
void ending(bool survived);
int main() {
srand(static_cast<unsigned int>(time(0))); // Seed for randomness
intro();
explore();
return 0;
}
// Function definitions
void intro() {
cout << "Welcome to *Echoes in the Dark*.\n";
cout << "You are Evelyn Hart, a paranormal investigator, exploring an abandoned
asylum.\n";
cout << "Your goal is to uncover the asylum's secrets and survive the night.\n\
n";
cout << "A storm rages outside as you approach the asylum...\n";
cout << "Press ENTER to continue...\n";
cin.ignore();
}
void explore() {
string choice;
cout << "\nYou enter the dark asylum. The air is cold, and the walls echo with
faint whispers.\n";
cout << "Where would you like to go?\n";
cout << "1. Infirmary\n";
cout << "2. Basement\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice == "1") {
infirmary();
} else if (choice == "2") {
basement();
} else {
cout << "\nInvalid choice. The asylum grows darker...\n";
explore();
}
}
void infirmary() {
cout << "\nYou enter the infirmary. The room is filled with overturned
furniture and broken equipment.\n";
cout << "A wheelchair moves on its own across the room...\n";
cout << "Suddenly, the door slams shut!\n";
cout << "Solve this puzzle to unlock the door:\n";
cout << "What is 6 + 9? ";
int answer;
cin >> answer;
if (answer == 15) {
cout << "\nThe door unlocks, and you escape the infirmary.\n";
explore();
} else {
cout << "\nYou failed to solve the puzzle. A ghostly figure emerges from
the shadows...\n";
cout << "GAME OVER. The asylum has claimed you.\n";
exit(0);
}
}
void basement() {
cout << "\nYou descend into the basement. It's pitch dark, and the air smells
of decay.\n";
cout << "You find a ritual circle and realize the spirits are trapped here.\n";
cout << "You must collect three ritual items to banish the spirits.\n";
int items = 0;
while (items < 3) {
cout << "\nYou search the room...\n";
if (rand() % 2 == 0) {
cout << "You found a ritual item!\n";
items++;
} else {
cout << "A ghost appears and whispers, 'You shouldn't be here.'\n";
}
}
cout << "\nYou have all the ritual items! Performing the ritual...\n";
cout << "Solve this final puzzle: What is 12 * 3? ";
int answer;
cin >> answer;
if (answer == 36) {
ending(true);
} else {
ending(false);
}
}