Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: c# example for particle system?  (Read 34584 times)

0 Members and 1 Guest are viewing this topic.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #15 on: August 29, 2013, 05:03:03 pm »
I can't really agree to start this new project as a team effort.. not at this time at least. That isnt to say that we can't help each other out with our individual games though.  :)

no problem, it was just an idea, because I'm still in testings things out.  :D
Your game is very fast at all. too fast for me....  ;D

Quote from: Mister
I will have the source code up as soon as I get a decent example running.  :D

I'm waiting.  :)
Meanwhile a short screen of my current particle test. It's not still, what I want to have...  :-\


edit
screenshot 2 + 3 look now much better, I think?
« Last Edit: August 29, 2013, 07:51:52 pm by Mad »
best regards,

Mad

Mister

  • Newbie
  • *
  • Posts: 22
  • Zomg
    • View Profile
Re: c# example for particle system?
« Reply #16 on: August 30, 2013, 05:38:39 am »
Looks pretty good so far -- is this a separate particle system that you are making? How'd you end up handling Particles Per Second?
Check out My Blog.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #17 on: August 30, 2013, 09:48:18 am »
Looks pretty good so far -- is this a separate particle system that you are making? How'd you end up handling Particles Per Second?

yes, it's my first experiment in SFML.  :)
I'm using the Stopwatch to get the milliseconds since last frame loop and calculate the new position with it.
best regards,

Mad

Mister

  • Newbie
  • *
  • Posts: 22
  • Zomg
    • View Profile
Re: c# example for particle system?
« Reply #18 on: August 30, 2013, 01:52:09 pm »


Here is a newer update of the particle system so far.
It now calculates the proper particles per second and fades out based on lifetime  ;D

I think I'll add color to it, clean up some spots, and then it should be good to upload to sourceforge -- just note that its nowhere near 100% done.   :)
« Last Edit: August 30, 2013, 01:54:29 pm by Mister »
Check out My Blog.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #19 on: August 30, 2013, 05:09:06 pm »
I think I'll add color to it, clean up some spots, and then it should be good to upload to sourceforge -- just note that its nowhere near 100% done.   :)

gogogo, I will see how you handle the drawing process.   :D
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: c# example for particle system?
« Reply #20 on: August 30, 2013, 07:32:03 pm »
Thanks for your information. I had a look at Thor early. It's a pitty there is no C# clone  :-\
But it seems to be a very useful library!!

Actually it does have an almost complete clone. I am currently working on it - particles and large texture/sprite/rendertexture are currently done. I will be publishing it soon too. And here is a screenshot of the ported fireworks example from Thor.

Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #21 on: August 30, 2013, 07:44:16 pm »
Actually it does have an almost complete clone. I am currently working on it - particles and large texture/sprite/rendertexture are currently done. I will be publishing it soon too. And here is a screenshot of the ported fireworks example from Thor.

YES, that are really good news!  :D
At the end, we will have 5 different Particlesystems here for different application areas. Cool  8)
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: c# example for particle system?
« Reply #22 on: August 30, 2013, 08:48:00 pm »
YES, that are really good news!  :D
At the end, we will have 5 different Particlesystems here for different application areas. Cool  8)

Glad you like the idea, I decided to go ahead and upload it. Here is the thread wherre you can read all about NetEXT.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #23 on: August 30, 2013, 09:03:48 pm »
Glad you like the idea, I decided to go ahead and upload it. Here is the thread wherre you can read all about NetEXT.

That was quick! Thanks for sharing.  :D I have the fireworks demo up and running. NICE!
I will have a deeper look into the lib to see what effects I can arrange with this particle system.  :D
best regards,

Mad

Mister

  • Newbie
  • *
  • Posts: 22
  • Zomg
    • View Profile
Re: c# example for particle system?
« Reply #24 on: September 01, 2013, 12:07:14 am »
https://sourceforge.net/projects/mparticles/

I still haven't added color but I cleaned it up a little bit.

I will be adding a lot to it over the course of Sunday-Monday so watch for updates  8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.
Check out My Blog.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #25 on: September 01, 2013, 01:17:12 pm »
Hi there!  :)

I will be adding a lot to it over the course of Sunday-Monday so watch for updates  8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.

First I have to say: Good structured souce code, mate!  :)

At the moment you use CircleShape for the smoke effect. Some plans to integrate texture effects?
I will have a deeper look later.  :)
best regards,

Mad

Mister

  • Newbie
  • *
  • Posts: 22
  • Zomg
    • View Profile
Re: c# example for particle system?
« Reply #26 on: September 01, 2013, 06:59:02 pm »
Hi there!  :)

I will be adding a lot to it over the course of Sunday-Monday so watch for updates  8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.

First I have to say: Good structured souce code, mate!  :)

At the moment you use CircleShape for the smoke effect. Some plans to integrate texture effects?
I will have a deeper look later.  :)

Thanks  :D

You can use whatever you like  8). All you gotta do is change CircleShape to a Sprite -- UserObject gets passed around per-particle and eventually gets cast into a Drawable and drawn to screen.

So basically, you could have ANY object that inherits from Drawable as UserObject and it will get drawn however you set it up and refresh the object.

For example -- I am making a fire work example particle effect; this is what I do:

                       
                public RocketEmitter() : base(1, 2)
                {
                        ParticleInitialization = SmokeParticleInit;

                        OnEveryUpdate += PresetAffectors.UpdatePositionBasedOnRotationAndVelocity;
                        OnRefreshUserObject += RefreshUserObject;

                        Texture texture = new Texture(@"Assets\rocket_triangle.png");

                        OnParticleCreated += particle =>
                        {
                                Sprite sprite = new Sprite(texture) {Origin = new Vector2f(20, 24), Scale = new Vector2f(.25f, .25f)};
                                particle.UserObject = sprite;
                        };
                }
 

And then I have this:

                private void RefreshUserObject(Particle particle)
                {
                        Sprite shape = (Sprite)particle.UserObject;
                        shape.Position = new Vector2f(particle.Position.X, particle.Position.Y);
                        shape.Color = new Color(0, 0, 0, (byte)particle.Alpha);
                        shape.Rotation = particle.Rotation;
                }
 

And then it draws rocket sprites on screen  :D

The smoke effect isn't quite done yet -- I will have something better committed soon  ;D
« Last Edit: September 01, 2013, 07:20:50 pm by Mister »
Check out My Blog.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #27 on: September 01, 2013, 08:00:17 pm »
Ah!  :D
so this way, you create a sprite for each particle?

In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry.  ::)

But my code is not clean at the moment and no time to work on it at currently  :-\
best regards,

Mad

Mister

  • Newbie
  • *
  • Posts: 22
  • Zomg
    • View Profile
Re: c# example for particle system?
« Reply #28 on: September 01, 2013, 08:50:03 pm »
Ah!  :D
so this way, you create a sprite for each particle?

In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry.  ::)

But my code is not clean at the moment and no time to work on it at currently  :-\

Yep that would be the better approach so we aren't wasting resources  ;)

I'll make sure the new examples reflects that.

EDIT:
I added Scaling and more functionality to how Alpha is dealt with.
« Last Edit: September 01, 2013, 09:06:57 pm by Mister »
Check out My Blog.

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: c# example for particle system?
« Reply #29 on: September 01, 2013, 09:06:18 pm »
Ah!  :D
so this way, you create a sprite for each particle?

In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry.  ::)

But my code is not clean at the moment and no time to work on it at currently  :-\

Yep that would be the better approach so we aren't wasting resources  ;)

I'll make sure the new examples reflects that.

So we can set the focus on groovy amazing and visionary effects soon ???   8)
best regards,

Mad