void World::Update(Snake& player) { auto currentPos = player.GetPosition(); if (currentPos == _item) { // Eat apple player.Extend(); player.IncreaseScore(); _msgCallback(std::string("Length +1 [") + std::to_string(player.GetLength()) + "]"); RespawnApple(); } int gridSizeX = _windowSize.x / _blockSize; int gridSizeY = _windowSize.y / _blockSize; if (currentPos.x <= 0 || currentPos.y <= 0 || currentPos.x >= gridSizeX - 1 || currentPos.y >= gridSizeY - 1) { // Out of bounds player.Lose(); } }