1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

deleting individual particles c#

Discussion in 'C#' started by clipsymaze, Dec 12, 2011.

  1. clipsymaze

    clipsymaze New Member

    Joined:
    Dec 12, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello everyone

    iam trying to delete individual particles, i tryed pos.x & pos.y aswell as the mouse position. but everything i tried gets an error.

    will really appreciate any contribution.

    code for particles:


    Code:
    float timeStep = m_Timer.Seconds;
    
    
    
    foreach (Particle particle in m_Particles)
    {
    particle.Update(timeStep);
    }
    m_TimeToNewParticle -= timeStep;
    while (m_TimeToNewParticle <= 0f)
    {
    float velXbl = (float)(randomNumberGenerator.NextDouble() + 0.1);
    float velYbl = (float)(randomNumberGenerator.NextDouble() + 0.1);
    
    float velXtr = (float)(randomNumberGenerator.NextDouble() - 1);
    float velYtr = (float)(randomNumberGenerator.NextDouble() - 1);
    
    m_Particles.Add(new Particle(new Vector2d(-2f, -2f), new Vector2d(velXbl, velYbl)));//bottom left
    m_Particles.Add(new Particle(new Vector2d(2f, 2f), new Vector2d(velXtr, velYtr))); //top right
    
    m_TimeToNewParticle += 2f / m_ParticlesPerSecond; //* and if there are too many, remove the oldest ones */
    if (m_Particles.Count > 2000)
    {
    m_Particles.RemoveAt(0);
    }
    


    second part of my particle code:


    Code:
    public Vector2d m_Position = new Vector2d(1.0f, 0.0f);
    public Vector2d m_Velocity = new Vector2d(0.0f, 0.0f);
    
    public float halfSize = 0.12f;
    
    
    public Particle(Vector2d pPosition, Vector2d pVelocity)
    {
    m_Position = pPosition;
    m_Velocity = pVelocity;
    
    }
    
    public void Update(float pTimeStep)
    {
    m_Position = m_Position.Add(m_Velocity.Multiply(pTimeStep));
    }
    
    public void Draw()
    {
    
    GL.glTexCoord2f(0.0f, 0.0f);
    GL.glVertex2f(-halfSize + m_Position.X, -halfSize + m_Position.Y);
    GL.glTexCoord2f(0.0f, 1.0f);
    GL.glVertex2f(-halfSize + m_Position.X, halfSize + m_Position.Y);
    GL.glTexCoord2f(1.0f, 1.0f);
    GL.glVertex2f(halfSize + m_Position.X, halfSize + m_Position.Y);
    GL.glTexCoord2f(1.0f, 0.0f);
    GL.glVertex2f(halfSize + m_Position.X, -halfSize + m_Position.Y);
    
    
    }
    
    public Vector2d GetPosition()
    {
    return m_Position;
    }
    
     

Share This Page