-
2 Attachment(s)
Creating an ASCII animal
Hello,
I am trying to create a program that will ultimately output a snake coiled around a stick Attachment 11389. Here is part of my code:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << "\n\n\n";
cout << "\t\t\t\t__ __ __ __ \n";
cout << "\t\t\t / " << "\\"<<" / " << "\\" << " / "<<"\\"<<" / "<<"\\";
cout <<"\n";
cout << "\t\t\t / "<< " \\"<<"/ " << " \\" << "/ "<<" \\"<<"/ "<<" \\";
cout <<"__________________";
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
return 0;
}
The problem occurs when I am trying to create the line where the snake will rest, I end up with a mess like this:Attachment 11390
Is there a way to have the line output the line so it can stretch across the whole length of the snake? Thanks in advance.
-
Well after messing around with the design one thing that might do what you want is whenever you have a "\\" in your code you could put a "_" there and that should make it look like the line is going through your snake. For the bottom you probably would have to do something similar and put it between two "\\" 's in your code so it shows up between them. I think this would help but I do not know for sure saying I myself am just starting to learn C++.
-
An update:
I realized what I was doing wrong now and I am going to constantly remind myself of it: always think of programming line by line, not as a whole. The reason for the ugly output was because I was printing to the end of the line all the while thinking it was the beginning. Even so, thanks for your reply thadis_4.
-
Yeah no problem I think reading stuff on the forums here are helping me saying even though I do not understand most of what people are doing I try to guess what the code is just by figuring out what they want it to do.