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

Recommended Answers

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 …

Jump to Post

As far as I know threading differs from platform to platform and perhaps even in compilers.

http://www.cplusplus.com/reference/thread/thread/

Jump to Post

All 5 Replies

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 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.