hello,

so i am having some problem

 x = 50; y = 31;                  //declaration from line 1 to 5


      lastx = x; lasty = y;
        while(1 == 1)

 {

 gotoxy(lastx, lasty);
 printf("         ");
 gotoxy(x,y);
 printf("**|_A_|**");
 a = getch();
 lastx = x; lasty = y;
 if (a == 77) x = x + 1;
 if (a == 75) x = x - 1;

 }
 //---------------------------------------------------------------------
 //i am facing problem here, i have these two codes but when i try to run only the character movement peice of code works, which is above this comment and the rand wont work which is below this comment.
 // so please help me how to make them work together, cause its a shooter game.. thanks


 while(1 == 1){
    gotoxy(x,y);
      printf("       ");
x1 = rand() % 3 + 50 ; y1 = 1;
 gotoxy(x1,y1);

thanks, though

Not really much to look at there and a lot of missing code, but I can say that your top while loop never seems to be broken out of so your second while loop will never be entered into.

If you want both of them to loop at the same time, then you will need to run one in a separate thread or process, then you are heading into a whole new area.

i posted only a bit of code in which i need help, obvio i wont ppost the whole code.

could you please throw some light on how to make them run at the same time.

unluckily my teacher hasnt allowed me to use them.

Then you will need to things in only the one loop.

Thing is, like I said it's difficult for people to advise properly with such a small amount of information.

Sorry I could not be of more help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.