December 2015
Beginner to intermediate
522 pages
11h 21m
English
Much like how a hammer is useless without someone using it, so are our two classes without being properly adopted by the Game class. Since we didn't write all that code just to practise typing, let's work on putting all the pieces together. First, we need to actually add two new members to the Game class, and you might already have guessed what they are:
class Game{
...
private:
...
World m_world;
Snake m_snake;
};Next, let's initialize these members. Since both of them have constructors that take arguments, it's the time for initializer list:
Game::Game(): m_window("Snake", sf::Vector2u(800, 600)),m_snake(m_world.GetBlockSize()),m_world(sf::Vector2u(800,600))
{
...
}Next, we need to process some input. As you may recall from the ...
Read now
Unlock full access