Reputation: 135
I'm making a simple, gravity based particle system, so I made three classes:
ParticleManager
, that store the particle system
ParticleSystem
, the VertexArray containing particles with an update function
Particle
, a Vertex inheriting from sf::Transformable.
Actually, I'm stuck with ParticleSystem
update function here's the code:
ParticleSystem()
{
particles.setPrimitiveType(PrimitiveType::Points);
int indexX = 0, indexY = 0;
for (int i = 1; i < CHUNK_SIZE; i++)
{
Particle particle;
particle.position = Vector2f(indexX, indexY);
particles.append(particle);
if (indexX < 100)
indexX++;
else
{
indexX = 0;
indexY++;
}
force.push_back(0);
}
}
void Update()
{
for (int i = 0; i < particles.getVertexCount(); i++)
{
particles[i].Update();
}
}
The compiler gives an error when calling particles[i].Update()
, because VertexArray can contain just sf::Vertex;
Any suggestion for implementing that function?
Upvotes: 0
Views: 96