I'm new to SFML so sorry if this is a noob question.
I'm trying to create a class for a fireworks show. The class will contain an std::list of structs to track each firework/shell. Inside each struct is also an std::vector of sf::VertexArrays (or sf::Vertex?) for the stars after the shell explodes.
Right now, I'm having problems drawing the shells and stars. Normally, an sf::VertexArray can be passed directly to draw funcion [myWindow.draw(myVertexArray)] but what if it's in a list and nested vector? Should this just be drawn using a loop & pointer? So what would be the correct way to draw the stars for each shell and then each shell in flight?
Another part that's confusing me, sf::VertexArray is a vector-like wrapper for sf::Vertex and can be passed directly to the draw() function. Is it possible to do something similar? I wasn't able to find the implementation, but does it also run through a loop or is there an easier way to draw my particles and/or shapes at once?
Firework.hpp
class Firework : public sf::Drawable, public sf::Transformable{
public:
private:
virtual void draw(sf::RenderTarget&, sf::RenderStates) const;
private:
struct Burst{
sf::Vertex vertex;
};
struct Flight{
sf::CircleShape circle;
std::vector<Burst> starProperties;
};
std::list<Flight> shell;
};
Firework.cpp
void Firework::draw(sf::RenderTarget& target, sf::RenderStates states) const {
states.transform *= getTransform();
// target.draw(starProperties.vertex);//no
// target.draw(shell.circle);//no
}
Each time the spacebar is pressed, a new shell is pushed onto the [shell] list with a random angle-velocity, X location and number of stars. This is with extraneous code removed; I can post the full (but broken) project as well.