Author Topic: MODULE: ParticleSystemManager v1.01  (Read 21307 times)

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #40 on: 25 Mar 2014, 18:13 »
I also found another bug. There seems to be an issue with function DrawingSurface.DrawImage(...) when the transparency given in parameter is 0. It crashes the game brutally, even in Debug mode.

The issue happens at this script line of the module :

Spoiler: ShowHide

Code: Adventure Game Studio
  1. surface.DrawImage (FloatToInt ( AllParticles[i].x ), FloatToInt ( AllParticles[i].y ), sprite.Graphic, AllParticles[i].transparency, width, height);
  2.  


If you want to avoid the error, then simply make sure that the transparency is never exactly zero.
For example you can add those two lines of script just before the line causing the error :


Spoiler: ShowHide

Code: Adventure Game Studio
  1. if (AllParticles[i].transparency ==0)
  2.     AllParticles[i].transparency = 1;
  3.  
  4. surface.DrawImage (FloatToInt ( AllParticles[i].x ), FloatToInt ( AllParticles[i].y ), sprite.Graphic, AllParticles[i].transparency, width, height);
  5.  



==========

However the issue mentionned by AGD2 remains : Sprites are drawn as blue cups.



the issue was found, it's not caused by the module.
« Last Edit: 26 Mar 2014, 18:20 by Monsieur OUXX »
 

Re: MODULE: ParticleSystemManager v1.01
« Reply #41 on: 25 Mar 2014, 22:09 »
However the issue mentionned by AGD2 remains : Sprites are drawn as blue cups.


I do not observe this effect, particles are drawn as normal sprites for me.

My code:
Code: Adventure Game Studio
  1.  
  2. function room_AfterFadeIn()
  3. {
  4.   ParticleSystemManager pm;
  5.   int psys = pm.CreateSystem(100, false, dtOverlay);
  6.   pm.emitter_creation_mode(psys, rmAllways, 100, 100, 5);
  7.   pm.emitter_set_position(psys, ptCirle, 100.0, 50.0, 150.0);
  8.   pm.emitter_set_sprite(psys, 0,  10);
  9.   pm.emitter_set_age(psys, 100, 5000);
  10. }
  11.  

Also I have no problem with transparency being 0... In fact transparency = 0 is default value for DrawImage function.
Does it happen to you if you call DrawImage yourself?

Can you post example of initialization code that causes such effect?
« Last Edit: 25 Mar 2014, 22:19 by Crimson Wizard »

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #42 on: 26 Mar 2014, 18:18 »
In the meantime I found the cause and it's really really stupid : DrawImage fails on backgrounds (with weird side effects) when you didn't explicitly set a background image for your room. I assumed the engine would just generate a black image. It doesn't. Any attempt to use the result of Room.GetDrawingSurfaceFromBackground() creates unpredictable effects.





==============
On a different topic :
Reupload of version 1.1 : http://www.adventuregamestudio.co.uk/forums/index.php?topic=50356.msg636486336#msg636486336


« Last Edit: 22 Apr 2014, 10:20 by Monsieur OUXX »
 

Re: MODULE: ParticleSystemManager v1.01
« Reply #43 on: 30 Apr 2015, 16:43 »
Hey!

Just a quick question (it might be about dynamic sprites in general but I'm not sure).

I'm running a 320x180 game and want to generate particles onto a 640x360 dynamic sprite - is this possible? I can only seem to get it to generate particles in a 320x180 bounding box, no matter what values I change :(

It's almost like the particles can only ever generate within a box set to the 320x180 resolution? E.g If I start generating particles on my 640x360 sprite and then move it 100 pixels to the left, the particles will disappear 100 pixels before reaching the right side of the screen.

Code:
Code: Adventure Game Studio
  1. ParticleSystemManager PS;
  2. DynamicSprite *sprStars;
  3.  
  4. function room_Load(){
  5.   sprStars = DynamicSprite.Create(640, 360, true);
  6.  
  7.   s = PS.CreateSystem(300, false, dtSprite, 640, 360);
  8.  
  9.   PS.emitter_creation_mode (s, rmAllways, 0, 1, 1);
  10.   PS.emitter_set_position (s, ptPoint, 160.0, 180.0);
  11.   PS.emitter_set_velocity (s, 1, 3, 0, 360);
  12.   PS.emitter_set_transparency (s, 0, 0);
  13.   PS.emitter_set_age (s, 900, 900);
  14.   PS.emitter_set_sprite (s, 11, 11);
  15.   PS.emitter_set_scale (s, 100, 100);
  16.  
  17.   PS.action_set_bound_box (s, 0, 0, 320, 360);
  18.   PS.action_add_force (s, ftParticleDirection, 0.3, 0.3);
  19.   PS.action_set_scale_evolution (s, 100, 1);
  20. }
  21.  
  22. function room_RepExec(){
  23.   sprStars = PS.GetSystemSprite(0);
  24.   oStars.Graphic = sprStars.Graphic;
  25. }
  26.  

Any ideas? I'm happy to provide a test game if anyone would be so kind as to have a look :)
Calico Reverie - Independent Game Development, Pixel Art & Other Stuff
Games: Mi - Starlit Grave - IAMJASON - Aractaur - blind to siberia - Wrong Channel - Memoriae - Point Of No Return

Re: MODULE: ParticleSystemManager v1.01
« Reply #44 on: 03 May 2015, 22:06 »
I finally got a bit of time to investigate this properly and it seems as though it's just hard-coded into the module. On the off-chance that anyone else needs something similar to this weird behaviour, I have explained below where to edit/patch.

Line 784-787:

Code: Adventure Game Studio
  1. // if particle is on screen
  2. if (FloatToInt (AllParticles[i].x) >= 0 && FloatToInt (AllParticles[i].x) < Room.Width &&
  3.     FloatToInt (AllParticles[i].y) >= 0 && FloatToInt (AllParticles[i].y) < Room.Height)
  4. {
  5.  

For my purposes I just changed Room.Width and Room.Height to what I needed and voila, particles can be generated off screen so that when I move my object that I am rendering onto, they are shown without an issue. :)
Calico Reverie - Independent Game Development, Pixel Art & Other Stuff
Games: Mi - Starlit Grave - IAMJASON - Aractaur - blind to siberia - Wrong Channel - Memoriae - Point Of No Return

Re: MODULE: ParticleSystemManager v1.01
« Reply #45 on: 04 May 2015, 01:13 »
I'm so glad you figured this out. I'm have a feeling this is going to come in handy sometime.
completed: Beyond Eternity

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #46 on: 04 May 2015, 09:59 »
Yes, this module has issues with scrolling backgrounds or anything bigger than 320x200, because it's hard-coded. Xil, it's a pity I saw your posts too late because I had corrected the issues in the version of this module that I use in my own game. I made other changes too, but xil if you have the opportunity you should upload your version of the module.
 

cat

  • Mittens Baronet
  • Global Moderator
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #47 on: 12 Apr 2016, 21:59 »
Hi!

I've tried this awesome module in Cogliostro's version and the effect looks awesome!

I just don't know how to stop if afterwards. I start the effect like this:

Code: Adventure Game Studio
  1. int s;    // system identifier
  2. s = PS.CreateSystem(140, false, dtBackground);
  3.  
  4. PS.emitter_creation_mode (s, rmAllways, 0, 2, 1);
  5. PS.emitter_set_position (s, ptPoint, 315.0, 95.0);
  6. PS.emitter_set_velocity (s, 90, 140, 240, 300);
  7. PS.emitter_set_age (s, 130, 140);
  8. PS.emitter_set_sprite (s, 1, 1);
  9. PS.emitter_set_scale(s, 50, 100);
  10.  
  11. PS.action_set_bound_box (s, 0, 0, 640, 270);
  12. PS.action_add_force (s, ftConstant, 0.0, 9.8);  
  13.  
  14. WaitSeconds(4.0);
  15.  
  16. while (PS.num_systems)
  17. {
  18.    PS.DeleteLastSystem();
  19. }
  20.  

The problem is, that all sprites stay stuck on screen after the effect is ended. How can I remove them?

Edit:

Ok, I've added
Code: Adventure Game Studio
  1. PS.emitter_set_age (s, 0, 0);      
  2. WaitSeconds(3.0);
  3.  
before the cleanup. It looks better, but there is now still one sprite flickering at the origin. Is ist possible, to just turn it off and wait, until all sprites are gone?
« Last Edit: 12 Apr 2016, 22:19 by cat »

Re: MODULE: ParticleSystemManager v1.01
« Reply #48 on: 12 Apr 2016, 22:39 »
Hi, I am not sure if this could be helpful but you could try to check the particle transparency so far.

Code: Adventure Game Studio
  1. PS.emitter_set_transparency (s, 100, 100);


Code: Adventure Game Studio
  1. PS.action_set_transparency_evolution (s, 100, 5);

I hope it helps :)

cat

  • Mittens Baronet
  • Global Moderator
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #49 on: 13 Apr 2016, 08:13 »
Ah, good idea, I'll try that.

cat

  • Mittens Baronet
  • Global Moderator
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #50 on: 13 Apr 2016, 19:13 »
Code: Adventure Game Studio
  1. PS.emitter_set_transparency (s, 100, 100);

Thanks, this did the trick! :)

Re: MODULE: ParticleSystemManager v1.01
« Reply #51 on: 14 Apr 2016, 01:14 »
I am glad to hear that you've solved it. :)

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #52 on: 16 Apr 2016, 15:06 »
If I recall, this module is not compatible with scrolling backgrounds, but it's rather easy to tweak to make it work, provided you know AGS well. It would be a good idea to post an update version. Also it's useful to replace the hard-coded width and height with System.ViewportWidth or such (forgot the exact name)
 

cat

  • Mittens Baronet
  • Global Moderator
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: MODULE: ParticleSystemManager v1.01
« Reply #53 on: 17 Dec 2016, 17:13 »
This module has problems with multiple backgrounds. To solve this, you have to change the module script:

Replace every occurrence of
Code: Adventure Game Studio
  1. Room.GetDrawingSurfaceForBackground();
with
Code: Adventure Game Studio
  1. Room.GetDrawingSurfaceForBackground(GetBackgroundFrame());

I am setting the frame of the background in room_Load, which seems to happen after event == eEventEnterRoomBeforeFadein in the module. So, the frame was not set yet.
What I did to solve this, is adding the following function to the module:
Code: Adventure Game Studio
  1. function ParticleSystemManager::RefreshBackground ()
  2. {
  3.    orig = Room.GetDrawingSurfaceForBackground(GetBackgroundFrame());
  4.    orig = orig.CreateCopy();
  5. }
I call this after setting the background frame of the room.

Re: MODULE: ParticleSystemManager v1.01
« Reply #54 on: 22 Jan 2017, 16:15 »
:@cat:

I had this issue for a long time but I never mentioned about it on this thread before.
I followed your instructions and it works wonderfully fine.
Thank you so much, I appreciated it very much.

The only thing that now remains to be pointed out is the fact that you can not change the background (repeatedly) without that all the particles remain on the screen... or probably somehow there could be a workaround to do that...