PDA

View Full Version : The following code has one simple error.....



bluehead
11-07-2001, 03:45 PM
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??

Xterria
11-07-2001, 03:46 PM
y-20? he he....

bluehead
11-07-2001, 03:47 PM
not that funny.....

ronin
11-08-2001, 09:41 AM
The if(b==x, y-20) looks a little odd.

Try something like

if((b == x) && (y == something))

then your cursor movement here

Jeremy G
11-08-2001, 07:45 PM
y -= 20;
if you were meaning to subtract 20 from y. and you MIGHT want to set y-=20; above the if statement, then just use y in the statement itself.