The snake class
Before designing any object, one must ask oneself what it needs. In our case, the snake needs to have a direction to move towards. It also needs to have lives, keep track of the score, its speed, whether it lost or not, and whether it lost or not. Lastly, we're going to store a rectangle shape that will represent every segment of the snake. When all these are addressed, the header of the snake class would look something like the following:
class Snake{ public: Snake(int l_blockSize); ~Snake(); // Helper methods. void SetDirection(Direction l_dir); Direction GetDirection(); int GetSpeed(); sf::Vector2i GetPosition(); int GetLives(); int GetScore(); void IncreaseScore(); bool HasLost(); void Lose(); // Handle losing here. void ToggleLost(); void Extend(); // Grow the snake. void Reset(); // Reset to starting position. void Move(); // Movement method. void Tick(); // Update method. void Cut(int l_segments...