How do I get information about the level to the player object?

Posted by pangaea on Game Development See other posts from Game Development or by pangaea
Published on 2013-11-06T15:22:14Z Indexed on 2013/11/06 16:15 UTC
Read the original article Hit count: 557

Filed under:
|

I have a design problem with my Player and Level class in my game.

So below is a picture of the game. The problem is I don't want to move on the black space and only the white space. I know how to do this as all I need to do is get the check for the sf::Color::Black and I have methods to do this in the Level class. The problem is this piece of code

   void Game::input()
{
    player.input();
}

void Game::update()
{
    (*level).update();
    player.update();
}

void Game::render()
{
    (*level).render();
    player.render();
}

So as you there is a problem in that how do I get the map information from the Level class to the Player class.

Now I was thinking if I made the Player position static and pass it into the Level as parameter in update I could do it. The problem is interaction. I don't know what to do. I could maybe make player go into the Level class. However, what if I want multiple levels?

So I have big design problems that I'm trying to solve.

enter image description here

© Game Development or respective owner

Related posts about c++

Related posts about sfml