samedi 24 octobre 2020

It is about the movement when pressing the arrow key inkeyboard. Can someone explain to me this code?

Thanks for your kindness and help. Much appreciate! Can someone explain to me this part of the coding:

      {
        if (GetAsyncKeyState(VK_UP)) {
            if (map[y - 1][x] == '.') { y--; pts++; }
            else if (map[y - 1][x] == ' ') y--;
        }
        if (GetAsyncKeyState(VK_DOWN)) {
            if (map[y + 1][x] == '.') { y++; pts++; }
            else if (map[y + 1][x] == ' ') y++;
        }
        if (GetAsyncKeyState(VK_LEFT)) {
            if (map[y][x - 1] == '.') { x--; pts++; }
            else if (map[y][x - 1] == ' ') x--;
        }
        if (GetAsyncKeyState(VK_RIGHT)) {
            if (map[y][x + 1] == '.') { x++; pts++; }
            else if (map[y][x + 1] == ' ') x++;
        }
      }

Aucun commentaire:

Enregistrer un commentaire