Jump to content
  • Advertisement
Sign in to follow this  

XNA 2D Particles :)

This topic is 2947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone sorry if I have mistakes with my English.. smile.gif
Im using XNA 3.1 and Im working on school project...so I decide to do 2D particle system!
I want to do something like this:


In the comments of the third video you can see that he wrote this:
"[font="arial, sans-serif"] i? used fixed function, and the movement of the particles is done using newtons laws,[/font]
[font="arial, sans-serif"] the cursor is an attractor and also the particles fall to the bottom of the[/font]
[font="arial, sans-serif"] screen with gravity. Its all done using a verlet integration technique."[/font]
[font="arial, sans-serif"]
[font="arial, sans-serif"]So i read about verlet integration and found:[/font]
[font="arial, sans-serif"]http://www.gamasutra...cobson_01.shtml[/font]

Please some one can help me to write the code?

this what I do for now: (the texture of each particle is 1X1 white picture for now)

class Particle
public Vector2 pos, oldpos, a; // pos-current position , oldpos-old position , a-Acceleration
public Color color;

public Particle(Vector2 _pos, Vector2 _oldpos, Vector2 _a, Color _color)
pos = _pos;
oldpos = _oldpos;
a = _a;
color = _color;

int WindowWidth = 800;
int WindowHeight = 800;

int MaxParticles;
Vector2 Gravity = new Vector2(0,-0.98f);
float TimeStep;

private void UpdateParticles()
Vector2 temp;
for (int i = 0; i < MaxParticles; i++)
temp = particles.pos;
particles.pos += particles.pos - particles.oldpos + particles.a * TimeStep * TimeStep;
particles.oldpos = temp;

private void DrawParticles()
for (int i = 0; i < MaxParticles; i++)
spriteBatch.Draw(particleTex, particles.pos, particles.color);


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!