Thread: Trying to make a truck drive accross the screen...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    6

    Trying to make a truck drive accross the screen...

    I have here an ansi truck, and I'm trying to get it to drive across the screen. It seems to be working... except for some reason the cab of the truck does not show up...


    Code:
    #include<stdio.h>
    #include<windows.h>
    #include <string.h>
    
    
    int main(void)
    {
        int N=50, i, speed=100, j;
        char line1[N], line2[N], line3[N], line4[N], line5[N], line6[N], line7[N];
        char line8[N], line9[N], line10[N], line11[N];
        int length1, length2, length3, length4, length5, length6, length7, length8;
        int length9, length10, length11;
        
        
        strncpy(line1,"                  _______________________________________________________        ",100);
        length1 = strlen(line1);
        
        strncpy(line2,"                  |                                                      |       ",100);
        length2 = strlen(line2);
        
        strncpy(line3,"             /    |                                                      |       ",100);
        length3 = strlen(line3);
        
        strncpy(line4,"            /---, |                                                      |       ",100);
        length4 = strlen(line4);
        
        strncpy(line5,"       -----# ==| |                                                      |       ",100);
        length5 = strlen(line5);
        
        strncpy(line6,"       | :) # ==| |                                                      |       ",100);
        length6 = strlen(line6);
        
        strncpy(line7,"  -----'----#   | |______________________________________________________|       ",100);
        length7 = strlen(line7);
        
        strncpy(line8,"  |)___()  '#   |______====____   \___________________________________|           ",100);
        length8 = strlen(line8);
        
        strncpy(line9," [_/,-,\"-- ------ //,-,  ,-,\\\   |/             //,-,  ,-,  ,-,\\ __#              ",100);
        length9 = strlen(line9);
        
        strncpy(line10,"   ( 0 )|===******||( 0 )( 0 )||-  o              '( 0 )( 0 )( 0 )||             ",100);
        length10 = strlen(line10);
        
        strncpy(line11,"----'-'--------------'-'--'-'-----------------------'-'--'-'--'-'--------------  ",100);
        length11 = strlen(line11);
        
    //   printf("%i %i %i %i %i %i %i %i %i %i %i\n", length1, length2, length3, length4, length5, length6, length7, 
    //                            length8, length9, length10, length11);
        
        system("cls");
        
        for(j=0;j<81;j++)
        {
            for(i=j;i<81;i++)
            {
                printf("%c", line1[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line2[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line3[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line4[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line5[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line6[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line7[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line8[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line9[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line10[i]);
            }
            printf("\n");
            for(i=j;i<81;i++)
            {
                printf("%c", line11[i]);
            }
            printf("\n");
            Sleep(speed);
            system("cls");
        }
    
    //                  _______________________________________________________\
    //                  |                                                      |
    //             /    |                                                      |
    //            /---, |                                                      |
    //       -----# ==| |                                                      |
    //       | :) # ==| |                                                      |
    //  -----'----#   | |______________________________________________________|
    //  |)___()  '#   |______====____   \___________________________________|
    // [_/,-,\"-- ------ //,-,  ,-,\\\   |/             //,-,  ,-,  ,-,\\ __#
    //   ( 0 )|===******||( 0 )( 0 )||-  o              '( 0 )( 0 )( 0 )||;
    //----'-'--------------'-'--'-'-----------------------'-'--'-'--'-'--------------
    
    system("pause");
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Apr 2011
    Posts
    6
    Figured it out... N value was too small... Switched it to 100 works good now... slight oversight

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. XNA - continuous obstacles accross the screen
    By RyanLeonard in forum Game Programming
    Replies: 2
    Last Post: 11-03-2010, 10:12 PM
  2. how to make copy of hard drive from HD recorder?
    By happyclown in forum Tech Board
    Replies: 1
    Last Post: 10-12-2009, 09:06 AM
  3. make the screen sleep
    By Headline in forum C++ Programming
    Replies: 2
    Last Post: 05-07-2008, 10:30 AM
  4. The ice cream truck song!
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-31-2003, 09:31 PM
  5. ESP not saved accross function call?
    By nickname_changed in forum C++ Programming
    Replies: 8
    Last Post: 08-11-2003, 11:23 AM