Reputation: 1002
I'm making a text based adventure game. I want to have the game name (marooned) in large or made out of lines. How can I do this?
An example of what I want is something like this:
╔═╗╔═╗───╔╗────────╔╗────╔╗─╔╗──╔╗╔╗────╔═══╦╗ ║║╚╝║║───║║────────║║────║║─║║──║║║║────╚╗╔╗║║ ║╔╗╔╗╠══╦╣║╔╦══╦╗─╔╣║╔══╗║╚═╝╠══╣║║║╔══╗─║║║║╚═╦══╦══╦══╗* ║║║║║║╔╗╠╣╚╝╣╔╗║║─║║║║╔╗║║╔═╗║║═╣║║║║╔╗║─║║║║╔╗║╔╗║╔╗║║═╣ ║║║║║║╔╗║║╔╗╣╔╗║╚═╝║╚╣╔╗║║║─║║║═╣╚╣╚╣╔╗║╔╝╚╝║║║║╚╝║╚╝║║═╣ ╚╝╚╝╚╩╝╚╩╩╝╚╩╝╚╩═╗╔╩═╩╝╚╝╚╝─╚╩══╩═╩═╩╝╚╝╚═══╩╝╚╩══╣╔═╩══╝ ───────────────╔═╝║───────────────────────────────║║ ───────────────╚══╝───────────────────────────────╚╝
but more visible. And also when this is compiled it comes out in ?
's. So I need the text to be compiler friendly.
Upvotes: 0
Views: 1421
Reputation: 73
There are multiple ways to do this.
The easiest way is to cout (char)<ASCII character code here> which will allow you to print those border characters instead of underscores and dashes.
A list of ASCII characters and their codes is at http://www.cplusplus.com/doc/ascii/.
You could also try dumping all that text in separate text file, read and parse the file, and then print it to the console.
Something like this:
#include <iostream>
#include <fstream>
#include <string>
int main() {
std::ifstream reader("art.txt"); //Load the text
std::string art = parseart(reader); //Parse the file
std::cout << art << std::endl; //Print
reader.close();
return 0;
}
std::string parseart(std::ifstream& File) {
std::string parsedfile;
if(File) {
while(File.good()) {
std::string tmpline;
std::getline(File, tmpline);
tmpline += "\n";
parsedfile += tmpline;
}
return parsedfile;
} else {
//Error
}
Upvotes: 0
Reputation: 126937
On Windows, go with wide string literals:
wchar_t * titleStr= L"╔═╗╔═╗───╔╗────────╔╗────╔╗─╔╗──╔╗╔╗────╔═══╦╗\n"
L"║║╚╝║║───║║────────║║────║║─║║──║║║║────╚╗╔╗║║\n"
L"║╔╗╔╗╠══╦╣║╔╦══╦╗─╔╣║╔══╗║╚═╝╠══╣║║║╔══╗─║║║║╚═╦══╦══╦══╗*\n"
L"║║║║║║╔╗╠╣╚╝╣╔╗║║─║║║║╔╗║║╔═╗║║═╣║║║║╔╗║─║║║║╔╗║╔╗║╔╗║║═╣ \n"
L"║║║║║║╔╗║║╔╗╣╔╗║╚═╝║╚╣╔╗║║║─║║║═╣╚╣╚╣╔╗║╔╝╚╝║║║║╚╝║╚╝║║═╣ \n"
L"╚╝╚╝╚╩╝╚╩╩╝╚╩╝╚╩═╗╔╩═╩╝╚╝╚╝─╚╩══╩═╩═╩╝╚╝╚═══╩╝╚╩══╣╔═╩══╝ \n"
L"───────────────╔═╝║───────────────────────────────║║ \n"
L"───────────────╚══╝───────────────────────────────╚╝\n"
std::wcout<<titleStr;
Upvotes: 3