I have got the new sfml game development by example book and I have been following the code for the snake program in chapter 3. When I get to the last part before running the program I get an error . In the void Game::Render() method i pass in the pointer *m_window.GetRenderWindow() to the m_world and m_snake but I get and error saying no operator "*" matches these operands type *Window. Also, I dont remember the book telling me to write a GetRenderWindow() method either. Can someone help me out please.
void World::Render(sf::RenderWindow &l_window)
{
for (int i = 0; i < 4; ++i)
{
l_window.draw(m_bounds);
}
l_window.draw(m_appleShape);
}
void Snake::Render(sf::RenderWindow& l_window)
{
if (m_snakeBody.empty()) { return; }
auto head = m_snakeBody.begin();
m_bodyRect.setFillColor(sf::Color::Yellow);
m_bodyRect.setPosition(head->position.x * m_size, head->position.y * m_size);
l_window.draw(m_bodyRect);
m_bodyRect.setFillColor(sf::Color::Green);
for (auto itr = m_snakeBody.begin() + 1; itr != m_snakeBody.end(); ++itr)
{
m_bodyRect.setPosition(itr->position.x * m_size, itr->poistion.y * m_size);
l_window.draw(m_bodyRect);
}
}
void Game::Render()
{
m_window.BeginDraw(); // clear
m_world.Render(*m_window.GetRenderWindow());
m_snake.Render(*m_window.GetRenderWindow());
m_window.EndDraw(); //display
}
my error occurs when I pass in the *m_window to the game render function. Also the book says to call those functions which I never made because the book never created those functions either