Hi! I'm new here to SFML. Just started using it 3 days ago or so. Today, I completed a Pong clone and now I'm working on a Tetris clone.
I'm looking for a more elegant solution for Tetroid creation/manipulation. I could divide each tetroid into it's own image and load them from there; however I would like to use as few images as possible. Currently, other than the UI Overlay I'm using, I only load 1 image, that being a single block.
void Tetroid::build(sf::Image &blockImg, tetType shape)
{
if (shape == Z)
{
focus.newBlock(blockImg, COLOR_Z);
focus.setDefaultPos();
block2.newBlock(blockImg, COLOR_Z);
block2.setDefaultPos();
block2.Up();
block3.newBlock(blockImg, COLOR_Z);
block3.setDefaultPos();
block3.Up(); block3.Left();
block4.newBlock(blockImg, COLOR_Z);
block4.setDefaultPos();
block4.Right();
} ...
}
I'm creating a Tetroid object out of 4 Block objects(which contain the block's sprite), setting one of those block objects as a focus and positioning the others around the focus. I do this for each shape.
As for movement...
void Tetroid::Left()
{
focus.Left();
block2.Left();
block3.Left();
block4.Left();
}
I'm just looking for suggestions on how to better go about creating/manipulating these objects. Would it be better to load 7 separate images and create sprites from each? Or make a sprite sheet containing each Tetroid and its respective rotations and SetSubRect it?
Like I said, I'm new to SFML, the Pong clone was the first multimedia based game I've ever created.
Any help would be greatly appreciated
edit: A little more information...
Obviously this will be addressing rotation as well. With my current setup, I will have to store the state of the active Tetroid as one of four rotational states, then SetPosition of each block around the focus for the rotation. This I could see as being advantageous as a solution for a rotation near the inactive blocks at the bottom of the field, to avoid clipping and detecting a collision, so a shape can be quick-rotated into a snug spot.
Anyways bed for me..zzzz