One simple error(IN DOS)

This is a discussion on One simple error(IN DOS) within the C++ Programming forums, part of the General Programming Boards category; The following code has one simple error: Undefined simbol 'B' can someone help me????? PS: i am making a simple ...

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269

    One simple error(IN DOS)

    The following code has one simple error: Undefined simbol 'B'
    can someone help me?????

    PS: i am making a simple invader game. so far no bullet is being shot but the object will be.
    _________________________________
    #include <iostream.h>
    #include <conio.h>
    #include <stdlib.h>

    int main()
    {
    {
    int b = 0;//B is the number 0
    int z = 25;
    int w = 5;
    gotoxy(z, w);
    putch(b);//puts the variable B at z, w coordinates.
    }
    int x = 15;
    int y = 25;
    int a = 1;
    while(a==1)
    {
    char cl = getch();
    if (cl==77)
    {
    clrscr();
    gotoxy(x++, y);
    putch('Y');
    gotoxy(x++, y);
    }
    if (cl==75)
    {
    clrscr();
    gotoxy(x--, y);
    putch('Y');
    gotoxy(x--, y);
    }
    if (cl==32)
    {
    if (b==x, y-20)//THE ERROR IS OVER HERE!!!!!
    {
    clrscr();
    gotoxy(x, y);
    putch('@');
    }
    }
    if (cl==27)
    {
    exit(0);
    }
    }
    return 0;
    }
    ____________________________________
    How do you fix it??
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  2. #2
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    so far no bullet is being shot but the object will be.
    I'm sorry, but i meant to say:
    so far no bullet is being shot but the 'B' will be terminated.
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  3. #3
    Quietly Lurking
    Join Date
    Aug 2001
    Posts
    208
    Maybe its just a typo but you cant have a ',' inside an if statement you proably want && (and) or ||(or)
    Proud to be a gun carrying, freedom loving, libertarian
    Don't listen to Right-Wing propaganda, legalize it NOW!

  4. #4
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    Maybe its just a typo but you cant have a ',' inside an if statement you proably want && (and) or ||(or)
    Doesn't do anything: it still has some error
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    11

    tried it

    I tried to compile it without the y-20 in your if statement and I get an error that states:
    implicit declaration of function `int gotoxy(...)'
    implicit declaration of function `int clrscr(...)'

  6. #6
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    I thought this game wuz gonna b simple!!!!
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  7. #7
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    the if statement has no idea what you want. Tell me in english what this line of code means:

    Code:
    if(b==x, y-20);
    also, for putch(b), do this:
    Code:
    putch('b');

  8. #8
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    The if (b==x, y-20)
    is supposed to check if the variable 'b' is at position x, y minus 20
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    61
    change:

    Code:
    int main() 
    { 
        { 
            int b = 0;//B is the number 0 
            int z = 25; 
            int w = 5; 
            gotoxy(z, w); 
            putch(b);//puts the variable B at z, w coordinates. 
        }
    to

    Code:
    int main() 
    { 
            int b = 0;//B is the number 0 
            int z = 25; 
            int w = 5; 
            gotoxy(z, w); 
            putch(b);//puts the variable B at z, w coordinates.
    the brackets ({}) tell the compiler that the code between them only exists between them. So since the variabels that you set up in between the brackets can only exist between them you wouldn't be able to use the variables anywere else in you're code unless you changed it.

  10. #10
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    do the collision detection like this:

    Code:
    if(x==13 && y==13)
    {//I am thinking that you are approaching a wall from the left
            gotoxy(x,y);
            putch(' ');
            x--;
            gotoxy(x,y);
            putch('@');
    }
    this says that if x=13 and y=13 then the '@' should move left one space so it doesn't go through the wall. Use for loops for this. Very useful for levels in your game.

  11. #11
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    trust me, I know. Here is a game I made about 10 months ago. I have the same game for windows, too. But this was one of my first games. All my other games I never give out cuz I convince myself they are never finished.
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Novice Question: MS DOS app. a console?
    By renurv in forum C++ Programming
    Replies: 7
    Last Post: 12-30-2005, 01:42 PM
  2. Instant Messenger for DOS
    By nitinol in forum C Programming
    Replies: 2
    Last Post: 12-21-2005, 09:17 PM
  3. simple 2d "putpixel" api for windows?
    By spiky in forum C Programming
    Replies: 2
    Last Post: 10-27-2005, 02:44 PM
  4. winver, winminor, winmajor can it be found from dos?
    By ronin in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-02-2002, 10:32 AM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 12:42 PM

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