-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphics.cpp
55 lines (46 loc) · 1.29 KB
/
graphics.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
44
45
46
47
48
49
50
51
52
53
#include "graphics.h"
#include <fstream>
#include <iostream>
using namespace std;
/**
* CREDIT TO THEMASSIVECHIPMUNK -> http://www.cplusplus.com/forum/general/58945/
*/
string getFileContents(std::ifstream &File) {
string Lines = ""; //All lines
if (File) //Check if everything is good
{
while (File.good()) {
std::string TempLine; //Temp line
std::getline(File, TempLine); //Get temp line
TempLine += "\n"; //Add newline character
Lines += TempLine; //Add newline
}
return Lines;
} else //Return error
{
return "ERROR File does not exist.";
}
}
/**
* Prints splash screen and creator info
*/
void graphics::drawLaunchGraphic() {
drawGraphicFromFile("splash.txt");
drawCreatorCredits();
}
/**
* Prints ASCII art from text file
* @param fileName
*/
void graphics::drawGraphicFromFile(std::string fileName) {
ifstream reader(fileName); //Open file
string Art = getFileContents(reader); //Get file
cout << Art << std::endl; //Print it to the screen
reader.close(); //close file
}
/**
* Prints out the creator info
*/
void graphics::drawCreatorCredits() {
drawGraphicFromFile("creator.txt");
}