Hi,
Ive looked through the published tutorials and some of the samples, but am still unclear on some of the best practices for designing a non-trival game.
e.g. the Drawable classes store position, rotation, etc with getters and setters. Obviously these classes don't have all the logic required for a game object, and so I need to make my own class that adds this logic. However I'm not clear on what the intended way to do this is, since there seems to be a few posibilites.
//A, inherit sf::Sprite and use its getters and setters directly for positional stuff
class Bullet : public sf::Sprite
{...};
//B, have sf::Sprite as a member, and use its getters and setters for positional stuff
class Bullet
{
private:
sf::Sprite spr;
public:
const sf::Vector2f& getPos()const{return spr.GetPosition();}
...
};
//C, have sf::Sprite as a member, have my own positional stuff, and set it in a render function
class Bullet
{
private:
sf::Sprite spr;
sf::Vector2f pos;
float direction;
public:
void render()
{
spr.SetPosition(pos);
...
}
...
};
Also does SFML do any rendering optimisation itself (i.e. look at what it was told to draw on the frame, and draw it such to avoid constant texture and state switches between every object), or have I got to do such batching myself? If so what are the recommended ways to do this where the Z order of the sprites is important and alpha blending is used (I had some previous success just putting all my games sprites in one big texture, so it could all be drawn in one big D3D batch)?
And one last thing. It looks like a major update to SFML is coming soon. Is it worth goign straight there rather than learning 1.6, and is there some resources around for doing so?
It would also be useful to see the code for somthing more complete that follows fairly good code practices. The best ive found so far is like that pong sample that stuck everything in the main function...