Jump to content
  • Advertisement
Sign in to follow this  
Concentrate

A quick question, about encapsulation

This topic is 2529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a IChessPIece class that encapsulates an sf::Sprite. sf::Sprite has its own interface. Would it be a better idea to have IChessPiece create a interface where it delegates its job to sf::Sprite, or would it be better to just returned sf::Sprite by reference? For example,

class IChessPiece{
void animateTo(...);
void showPossibleMoveLoaction(GameBoard& board);

sf::Sprite getSprite()const{ return m_sprite; }
sf::Sprite getSprite()const{ return m_sprite; }
public:
sf::Sprite m_sprite;
enum { PAWN, KNIGHT, ... };
};


or


class IChessPiece{
void animateTo(...);
void showPossibleMoveLoaction(GameBoard& board);

void setLocation(..){ m_sprite.SetLocation(...); }
void setSize(...){ m_sprite.SetSize(...); }
//.. and so on
public:
sf::Sprite m_sprite;
enum { PAWN, KNIGHT, ... };

};

Or maybe a possible combination of the two to make it easier on the user? All works, I guess, but just seeing what you guys thought about it.

Share this post


Link to post
Share on other sites
Advertisement
That type looks confused, is it a model or a viewmodel?

Can't figure out how to edit on phone screen, hit post by accident, meant to add it's mixing MVVM concerns.

When will a decent mobile version of this site be available, like the old one?

Share this post


Link to post
Share on other sites
Hidden
Can't figure out how to edit on phone screen, hit post by accident, meant to add it's mixing MVVM concerns.

When will a decent mobile version of this site be available, like the old one?

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!