weird cpp error

Discussion in 'Software' started by alarm, Oct 29, 2004.

  1. alarm

    alarm Private First Class

    when I run this, it doesn't do what it's supposed to. It's an ascii space invaders game(my first game programming project). It's supposed to go left when you press a, and right when you press d.


    #include <stdio.h> // for printf
    #include <conio.h> // for getch
    #include <string.h>
    #include <iostream.h>



    char espace_vaisseau[76];
    char left_right;
    int espace = 39;
    int count;
    int loop;

    main ()
    {
    strcpy(espace_vaisseau, " "); // graphics pour le vaisseau



    cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

    cout << "^W^" << espace_vaisseau ; // afficher vaisseau

    for(loop = 0; loop < 4; loop + 0) // infinite loop; while didn't work
    {
    if((left_right = getch()) == 'a')
    {
    espace--;
    }
    else if ((left_right = fetch()) == 'd')
    {
    espace++;
    }
    if (espace < 0)
    {
    espace++;
    }
    else if (espace > 76)
    {
    espace--;
    }

    for (count = 0; count <= espace; count++)
    {
    espace_vaisseau[count]=' ';
    }

    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

    printf("%s^W^", espace_vaisseau); // afficher vaisseau
    }

    return (0);
    }
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds