#include <iostream>
#include <string>
#include <chrono>
#include <thread>
using namespace std;
// Magical paper printing Method.. dont touch. (un)
static void print(string tempString, string tempString1, int end) {
if (((tempString != "") && (tempString1 != "") && (end == 1))) {
cout << tempString << " " << tempString1 << endl;
} else if (((tempString != "") && (tempString1 != "") && (end == 0))) {
cout << tempString << " " << tempString1;
} else if (((tempString != "") &&& (tempString1 = "") && (end == 1))) {
cout << tempString << endl;
} else if (((tempString != "") && (tempString1 != "") && (end == 0))) {
cout << tempString;
} else {
cout << "Error: inside Pandora_Box.print(), Could not print \n";
}
}
// A rare method from the future that stops time.
static void threadSleep(int newMilliseconds) {
std::this_thread::sleep_for(std::chrono::milliseconds(newMilliseconds));
}
//---------------------MAIN_SCREEN-----------------------------------------
class mainScreen {
public:
static void newScreen();
static void screen();
static void loading();
};
void mainScreen::newScreen() {
for (int i = 0; i < 26; i++) {
cout << " " << endl;
}
}
void mainScreen::screen() {
cout << "===============================================================================" << endl;
cout << "|===================== =====================|" << endl;
cout << "| []===================================[] |" << endl;
cout << "| [] [] |" << endl;
cout << "| [] =============================== [] |" << endl;
cout << "| [] | --------------------------- | [] |" << endl;
cout << "| [] | Do you want to open the box | [] |" << endl;
cout << "| [] | --------------------------- | [] |" << endl;
cout << "|___________________[] =============================== []___________________|" << endl;
cout << "|===================[]++ ++[]===================|" << endl;
cout << "| []_______________________________[] |" << endl;
cout << "| []===========================[] |" << endl;
cout << "| []__ |---------| __[] |" << endl;
cout << "| [--------------] []__ | [=] | __[] [--------------] |" << endl;
cout << "| |++++++++++++++| ++[]__|=========|__[]++ |++++++++++++++| |" << endl;
cout << "| [--------------] ++ ++ [--------------] |" << endl;
cout << "| ++ ++ |" << endl;
cout << "| ++ ++ |" << endl;
cout << "| ++ _______________ ++ |" << endl;
cout << "| ++__[]+++++++++++[]__++ |" << endl;
cout << "| ++[]+++++++++++++++[]++ |" << endl;
cout << "| __[]+++++++++++++++++++[]__ |" << endl;
cout << "|=======================[][][][][][][][]|[][][][][][][]=======================|" << endl;
cout << "===============================================================================" << endl;
string welcome_screen_var1; bool welcome_gate;
getline(cin, welcome_screen_var1);
if ((welcome_screen_var1 == "yes") || (welcome_screen_var1 == "Yes")) {
welcome_gate = true;
} else if ((welcome_screen_var1 == "no") || (welcome_screen_var1 == "No")) {
welcome_gate = true;
} else {
cout << "Error: Invalid input from -> welcome_screen_var1";
}
}
void mainScreen::loading() {
try {
string loading_message[4] = { "Welcome", "Welcome to", "Welcome to Pandora's", "Welcome to Pandora's Box" };
threadSleep(300);
newScreen();
for (int j = 0; j <= 4; j++) {
cout << "\t\t\t" << loading_message[j] << endl;
threadSleep(600);
newScreen();
if (j == 4) {
threadSleep(1000);
}
}
} catch (const char* msg) {
cout << msg << endl;
}
}
//-------------------GAME_CORE--------------------------------------------
class gameCore {
public:
static void gameLoop();
};
void gameCore::gameLoop() {
// mainScreen gaemLoop Constructor
mainScreen sc2;
// Methods to Run
sc2.screen();
sc2.loading();
}
//-----------------------------------------------------------------------------
int main() {
// Constructors;
mainScreen sc;
gameCore gc;
// Methods in chrono. Order
gc.gameLoop();
//====Return&pause=====
system("pause");
return 0;
}
When I searched for the error, I found many answers, but not a definite one, and they seemed to help just "their" code, anyway I couldn't find a way to fix it over time looking at stuff but here anyways.
When I compile the code (using visual studio community C++), I get a error,
error:
First-chance exception at 0x58627EA6 (msvcp120d.dll) in program.exe: 0xC0000005: Access violation reading location 0x4F377C2A.
If there is a handler for this exception, the program may be safely continued.
It runs pretty good and does it what it needs to do, but then it pops up with this error, also i know this probably has to do with the mainScreen::Loading() method.
I'm pretty new to C++ (about 2-3 weeks), so i don't know much, if anyone can maybe help with removing unnecessary lines, or structuring, that would be great.
Also if there is a question I may have not found, and a solution to this is on there, please reply, and thanks in advance..
for (int j = 0; j <= 4; j++)
must be
for (int j = 0; j < 4; j++)
in void mainScreen::loading().
as a consequence the test
if (j == 4)
should then be
if (j == 3)