8 Replies - 10736 Views - Last Post: 28 March 2013 - 03:30 PM Rate Topic: -----

#1 stefan1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-February 09

display ascii art in c++

Posted 24 February 2009 - 08:44 PM

hello my name is stefan and im a noob proramming with c++

im doing a little rpg game for my class is a project we have and im trying to make a cool intro showing some ascii art

but i have no idea how to do this i tried using cout<< and pasting whole thing there and then putting ; at the end but it doesnt display and it has all sorts of errors what can i do to make it display it? can i use cout or do i have to use another code?

this is the drawing

Dragons
&
Knights
	

				   {}
   ,   A		   {}
  / \, | ,		.--.
 |	=|= >	  /.--.\
  \ /` | `	   |====|
   `   |		 |`::`|  
	   |	 .-;`\..../`;_.-^-._
	  /\\/  /  |...::..|`   :   `|
	  |:'\ |   /'''::''|   .:.   |
	   \ /\;-,/\   ::  |..ASCII..|
	   |\ <` >  >._::_.| ':ART:' |
	   | `""`  /   ^^/>  |   ':'   |
	   |	   |	   \	:	/
	   |	   |		\   :   / 
	   |	   |___/\___|`-.:.-`
	   |		\_ || _/	`
	   |		<_ >< _>
	   |		|  ||  |
	   |		|  ||  |
	   |	   _\.:||:./_
	   | jgs  /____/\____\

.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:
.

if you can help me out with this i be greatly appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: display ascii art in c++

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4189
  • View blog
  • Posts: 11,863
  • Joined: 18-April 07

Re: display ascii art in c++

Posted 24 February 2009 - 08:52 PM

It is going to take a bit of hard work to do ascii art. You are going to use cout for each line (or printf may work better) with the proper counting of spaces each. Think of creating a triangle in C++. You will be using the same similar style to create your pictures.

:)

p.s. you can try showing us your code if you are getting errors. We can then help you with those.

This post has been edited by Martyr2: 24 February 2009 - 08:53 PM

Was This Post Helpful? 0
  • +
  • -

#3 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 515
  • Joined: 14-January 09

Re: display ascii art in c++

Posted 24 February 2009 - 09:26 PM

My bet is you've got a few messed up escape characters? \ <---gotta have \\ or it'll think its a escape character.
Was This Post Helpful? 0
  • +
  • -

#4 Hyper  Icon User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: display ascii art in c++

Posted 26 February 2009 - 10:13 AM

JGS has done alot of ASCII art. Although I've never seen that one paticuarly, looks neat.

You must realize, in a console (unless it's full-screen), you're limited to 25 (or 50) vertical lines, and 80 (full screen or not) horizontal.

By "lines" I mean "characters." A character can be (obviously) anything printable to the screen.

Here's a sword I drew via ASCII art:
     *
     *
    ***
  *** ***
    * *
    * *
    * *
    * *
    * *
    * *
    * *
     *


Animating it's pretty easy. :)

This post has been edited by Hyper: 26 February 2009 - 10:14 AM

Was This Post Helpful? 0
  • +
  • -

#5 stefan1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-February 09

Re: display ascii art in c++

Posted 26 February 2009 - 03:35 PM

Quote

My bet is you've got a few messed up escape characters? \ <---gotta have \\ or it'll think its a escape character.


yes i did got alot of messed up escape characters and even when i put the thing around the cout<<"" in quotations the thing got confused with the drawing quotations

Quote

printf may work better


Quote

how do you use printf for this?

JGS has done alot of ASCII art. Although I've never seen that one paticuarly, looks neat.

You must realize, in a console (unless it's full-screen), you're limited to 25 (or 50) vertical lines, and 80 (full screen or not) horizontal.

By "lines" I mean "characters." A character can be (obviously) anything printable to the screen.

Here's a sword I drew via ASCII art:


ahh thank you very much i try to put this one into my program see how it fits i let you know how it goes
Was This Post Helpful? 0
  • +
  • -

#6 Hyper  Icon User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: display ascii art in c++

Posted 26 February 2009 - 03:38 PM

Welcome?

printf is more readable than cout sometimes.

This post has been edited by Hyper: 26 February 2009 - 03:39 PM

Was This Post Helpful? 0
  • +
  • -

#7 programble  Icon User is offline

  • (cons :dic :head)

Reputation: 49
  • View blog
  • Posts: 1,315
  • Joined: 21-February 09

Re: display ascii art in c++

Posted 26 February 2009 - 03:49 PM

Change all \s to \\s.
Was This Post Helpful? 0
  • +
  • -

#8 Hyper  Icon User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: display ascii art in c++

Posted 26 February 2009 - 03:51 PM

programble, I think he got that already... and just-in-case:

printf("  / \\, | ,        .--.\n");
printf(" |    =|= >      /.--.\\");

This post has been edited by Hyper: 26 February 2009 - 03:52 PM

Was This Post Helpful? 0
  • +
  • -

#9 CodeNubee  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 28-March 13

Re: display ascii art in c++

Posted 28 March 2013 - 03:30 PM

You can it in cout. it works for me.

cout << "                  {}\n";
cout << "  ,   A           {}\n";
cout << " / \\, | ,        .--.\n";
cout << "|  =|= >        /.--.\\\n";
cout << " \\ /` | `       |====|\n";
cout << "  `   |         |`::`|\n";
cout << "      |     .-;`\\..../`;_.-^-._\n";
cout << "     /\\\\/  /  |...::..|`   :   `|\n";
cout << "     |:'\\ |   /'''::''|   .:.   |\n";
cout << "      \\ /\\;-,/\\   ::  |..ASCII..|\n";
cout << "      |\\ <` >  >._::_.| ':ART:' |\n";
cout << "      | `""`_/   ^^/>/>  |   ':'   |\n";
cout << "      |       |       \\    :   /\n";
cout << "      |       |        \\   :   /\n";
cout << "      |       |___/\\___|`-.:.-`\n";
cout << "      |        \\_ || _/    `\n";
cout << "      |        <_ >< _>\n";
cout << "      |        |  ||  |\n";
cout << "      |        |  ||  |\n";
cout << "      |       _\\.:||:./_\n";
cout << "      | jgs  /____/\\____\\\n";
cout << "\n";
cout << ".:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:" << endl;
system ("pause");



or you can do it with printf. This also works for me.
printf("                  {}\n");
printf("  ,   A           {}\n");
printf(" / \\, | ,        .--.\n");
printf("|  =|= >        /.--.\\\n");
printf(" \\ /` | `       |====|\n");
printf("  `   |         |`::`|\n");
printf("      |     .-;`\\..../`;_.-^-._\n");
printf("     /\\\\/  /  |...::..|`   :   `|\n");
printf("     |:'\\ |   /'''::''|   .:.   |\n");
printf("      \\ /\\;-,/\\   ::  |..ASCII..|\n");
printf("      |\\ <` >  >._::_.| ':ART:' |\n");
printf("      | `""`_/   ^^/>/>  |   ':'   |\n");
printf("      |       |       \\    :   /\n");
printf("      |       |        \\   :   /\n");
printf("      |       |___/\\___|`-.:.-`\n");
printf("      |        \\_ || _/    `\n");
printf("      |        <_ >< _>\n");
printf("      |        |  ||  |\n");
printf("      |        |  ||  |\n");
printf("      |       _\\.:||:./_\n");
printf("      | jgs  /____/\\____\\\n");
printf("\n");
printf(".:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:\n");
system ("pause");


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1