Creating an ASCII animal

This is a discussion on Creating an ASCII animal within the C++ Programming forums, part of the General Programming Boards category; Hello, I am trying to create a program that will ultimately output a snake coiled around a stick . Here ...

  1. #1
    Do you C what I C? jamesallen4u's Avatar
    Join Date
    Oct 2011
    Posts
    43

    Creating an ASCII animal

    Hello,

    I am trying to create a program that will ultimately output a snake coiled around a stick Name:  snake.png
Views: 977
Size:  3.4 KB. 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:Name:  snakeoutput.png
Views: 471
Size:  46.8 KB

    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.
    Linux Distro: Ubuntu 12.04
    Browser: Chromium

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    34
    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++.

  3. #3
    Do you C what I C? jamesallen4u's Avatar
    Join Date
    Oct 2011
    Posts
    43
    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.
    Linux Distro: Ubuntu 12.04
    Browser: Chromium

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    34
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Babies cuteness in the animal world, technical term
    By Mario F. in forum General Discussions
    Replies: 2
    Last Post: 10-13-2010, 10:52 PM
  2. ascii
    By shardin in forum C Programming
    Replies: 6
    Last Post: 09-05-2007, 03:08 PM
  3. ASCII character with ASCII value 0 and 32
    By hitesh_best in forum C Programming
    Replies: 4
    Last Post: 07-24-2007, 10:45 AM
  4. Animal Cruelty
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 05-13-2005, 08:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21