samedi 19 septembre 2020

I need help understanding what the syntax of this particular if statement accomplishes

Im trying to follow along and break down a the source code for a pacman clone. There is an if statement that im confused about.

void PacMan::queueDirection(Direction dir)
{
    if (!directions.empty())
    {
        if (dir == -directions.front()) //this statement
        {
            std::queue<Direction> clear;
            std::swap(directions, clear);
        }
    }

    if(directions.size() < 2)
        directions.push(dir);
}

My question is what does the - infront of -directions.front() do? directions is a queue. Does it multiply the reference returned by front() by -1? Thanks for the help - ill post a link below to the github where the whole project is. https://github.com/HexagonNico/Pac-Man/blob/master/PacMan.cpp if that tickles your fancy.

Aucun commentaire:

Enregistrer un commentaire