MODULE: ParticleSystemManager v1.01

Started by jerakeen, Mon 26/01/2009 19:57:29

Previous topic - Next topic

Monsieur OUXX

#40
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

Code: ags

surface.DrawImage (FloatToInt ( AllParticles[i].x ), FloatToInt ( AllParticles[i].y ), sprite.Graphic, AllParticles[i].transparency, width, height);

[close]

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

Code: ags

if (AllParticles[i].transparency ==0)
    AllParticles[i].transparency = 1;

surface.DrawImage (FloatToInt ( AllParticles[i].x ), FloatToInt ( AllParticles[i].y ), sprite.Graphic, AllParticles[i].transparency, width, height);

[close]


==========

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



the issue was found, it's not caused by the module.
 

Crimson Wizard

#41
Quote from: Monsieur OUXX on Tue 25/03/2014 18:13:49
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: ags


function room_AfterFadeIn()
{
  ParticleSystemManager pm;
  int psys = pm.CreateSystem(100, false, dtOverlay);
  pm.emitter_creation_mode(psys, rmAllways, 100, 100, 5);
  pm.emitter_set_position(psys, ptCirle, 100.0, 50.0, 150.0);
  pm.emitter_set_sprite(psys, 0,  10);
  pm.emitter_set_age(psys, 100, 5000);
}


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?

Monsieur OUXX

#42
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


 

xil

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: ags

ParticleSystemManager PS;
DynamicSprite *sprStars;

function room_Load(){
  sprStars = DynamicSprite.Create(640, 360, true);
  
  s = PS.CreateSystem(300, false, dtSprite, 640, 360);
  
  PS.emitter_creation_mode (s, rmAllways, 0, 1, 1);
  PS.emitter_set_position (s, ptPoint, 160.0, 180.0);
  PS.emitter_set_velocity (s, 1, 3, 0, 360);
  PS.emitter_set_transparency (s, 0, 0);
  PS.emitter_set_age (s, 900, 900);
  PS.emitter_set_sprite (s, 11, 11);
  PS.emitter_set_scale (s, 100, 100);
  
  PS.action_set_bound_box (s, 0, 0, 320, 360);
  PS.action_add_force (s, ftParticleDirection, 0.3, 0.3);
  PS.action_set_scale_evolution (s, 100, 1);
}

function room_RepExec(){
  sprStars = PS.GetSystemSprite(0);
  oStars.Graphic = sprStars.Graphic;
}


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

xil

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: ags

// if particle is on screen
if (FloatToInt (AllParticles[i].x) >= 0 && FloatToInt (AllParticles[i].x) < Room.Width &&
    FloatToInt (AllParticles[i].y) >= 0 && FloatToInt (AllParticles[i].y) < Room.Height)
{


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

MyEakinBack

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

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

#47
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: ags

int s;    // system identifier
s = PS.CreateSystem(140, false, dtBackground);

PS.emitter_creation_mode (s, rmAllways, 0, 2, 1);
PS.emitter_set_position (s, ptPoint, 315.0, 95.0);
PS.emitter_set_velocity (s, 90, 140, 240, 300);
PS.emitter_set_age (s, 130, 140);
PS.emitter_set_sprite (s, 1, 1);
PS.emitter_set_scale(s, 50, 100);

PS.action_set_bound_box (s, 0, 0, 640, 270);
PS.action_add_force (s, ftConstant, 0.0, 9.8);  

WaitSeconds(4.0);

while (PS.num_systems)
{
   PS.DeleteLastSystem();
}


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: ags

PS.emitter_set_age (s, 0, 0);      
WaitSeconds(3.0);

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?

Vincent

Hi, I am not sure if this could be helpful but you could try to check the particle transparency so far.

Code: ags

PS.emitter_set_transparency (s, 100, 100); 



Code: ags

PS.action_set_transparency_evolution (s, 100, 5); 


I hope it helps :)

cat


cat

Quote from: Vincent on Tue 12/04/2016 22:39:37
Code: ags

PS.emitter_set_transparency (s, 100, 100); 


Thanks, this did the trick! :)

Vincent

I am glad to hear that you've solved it. :)

Monsieur OUXX

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

This module has problems with multiple backgrounds. To solve this, you have to change the module script:

Replace every occurrence of
Code: ags

Room.GetDrawingSurfaceForBackground();

with
Code: ags

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: ags

function ParticleSystemManager::RefreshBackground ()
{
   orig = Room.GetDrawingSurfaceForBackground(GetBackgroundFrame());
   orig = orig.CreateCopy();
}

I call this after setting the background frame of the room.

Vincent

:@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...

SMF spam blocked by CleanTalk