How can I make a switch run in parallel with another switch?

0

I made this code to move a character to a college job, but I wish that when I pressed the 'a', I could still walk and the ship would not be erased, just as I could press the 'a' several times and I got a lot of shots, I took a look at the pthread but I do not know how to apply in that case, if I knew otherwise it would also help a lot. I do not know if pthread is the right one, since I use windows.

struct posicao nave_pos = {0,37,'A'};
struct posicao laser_pos = {0,36,'^'};
 void movimentacao_nave()
{
nave_pos.x = 40;
nave_pos.y = 37;
char C;

do
{
    gotoxy(nave_pos.x,nave_pos.y);
    printf("%c", nave_pos.c);
    C=getch();
    system("cls");
    switch(C)
    {
    case 75:
        nave_pos.x=nave_pos.x-1;
        if(nave_pos.x==0)
            nave_pos.x=nave_pos.x+1;
        break;
    case 77:
        nave_pos.x=nave_pos.x+1;
        if(nave_pos.x>83)
            nave_pos.x=nave_pos.x-1;
        break;
    case 'a':
            laser_pos.x = nave_pos.x;
for(laser_pos.y = 37 ; laser_pos.y > 0 ; laser_pos.y--)
{
    gotoxy(laser_pos.x,laser_pos.y);
    printf("%c", laser_pos.c);
    Sleep(50);
    system("cls");
}
        break;
    }

}
while(1);
 }
    
asked by anonymous 11.07.2018 / 16:07

0 answers