MODULE: ParticleSystemManager v1.01

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

Previous topic - Next topic

abstauber

Thanks for this new release (and mentioning me  := )!

I'm sure, there are a lot projects which will love your module. Any chance, you make something else this fancy?  ;D

jerakeen

i'm afraid not. I had no time to implement further changes right now.

I was thinking on implement something like rules, so when a condition is meet then an action or change on particles is done.

Something like if particle's age is greater than 12 change sprite, or if there are 20 particles on the system change the force.

i thing this will useful to make the system change, for example change fire into smoke.

But this will be to many code and i got no time by now.


DavidCB

There is a small problem in this new version of AGS, RawSaveScreen and RawRestoreScreen are unknown commands.
If you want to replace with DrawingSurface, you need global variables.

jerakeen

Quote from: DavidCB on Wed 10/06/2009 08:30:12
There is a small problem in this new version of AGS, RawSaveScreen and RawRestoreScreen are unknown commands.
If you want to replace with DrawingSurface, you need global variables.

I know, because of this, there is a new version of the module, in the original post there is a new link to the "release" ModuleParticleSystemManager v1.01

R4L

Hello, I don't mean to bump an old topic, but could you help me please?

I'm using AGS 3.1, and I'm trying to set up some rain to fall in a room. I'm following the readme, but I keep getting a parse error. I haven't scripted anything in a while, so it could be that I'm placing things in the wrong spots, or just flat out doing it wrong.

Here's my room script:

Code: ags
// room script file

int num_systems;

function CreateSystem (int 25, bool keep_track = false, enDrawType draw_type = dtBackground, int width = 640 , int height = 480);

function emitter_creation_mode (int system, enRepeatMode rmAllways, int max_rep, int 40, int 2);


I know something is wrong, I just can't figure it out. Any help is greatly appreciated. :)

Dualnames

Quote from: R4L on Mon 28/12/2009 14:51:07
Hello, I don't mean to bump an old topic, but could you help me please?

I'm using AGS 3.1, and I'm trying to set up some rain to fall in a room. I'm following the readme, but I keep getting a parse error. I haven't scripted anything in a while, so it could be that I'm placing things in the wrong spots, or just flat out doing it wrong.

Here's my room script:

Code: ags
// room script file

int num_systems;

function CreateSystem (int 25, bool keep_track = false, enDrawType draw_type = dtBackground, int width = 640 , int height = 480);

function emitter_creation_mode (int system, enRepeatMode rmAllways, int max_rep, int 40, int 2);


I know something is wrong, I just can't figure it out. Any help is greatly appreciated. :)

Here's what I'm using for Hitchhiker's

Code: ags


//I use the following part into a module.

ParticleSystemManager PS;
int wind_force_index;
float wind_force;



function ParticleEffects(int effect) {
if (effect==1) {//Smoke Effect
int s;    
s = PS.CreateSystem(240, false, dtBackground);
PS.emitter_creation_mode(s, rmAllways, 0, 1, 25);
PS.emitter_set_position(s, ptPoint,16.5, 41.0); 
PS.emitter_set_sprite (s, 931, 941);
PS.emitter_set_velocity (s, 10, 30, 270, 310);
PS.emitter_set_transparency (s, 71, 99);
PS.emitter_set_age (s, 100, 200);
wind_force = 1.5;
wind_force_index = PS.action_add_force (s, ftConstant, wind_force, 0.0);
PS.action_add_force (s, ftRandom, -2.0, 0.0, 2.0, 0.0);
PS.action_set_transparency_evolution (s, 100, 7); 
PS.action_set_bound_box (s, 0, 0, 320, 120);
}
if (effect==2) {//Wind Effect
int s;
s = PS.CreateSystem(100, false, dtBackground);
PS.emitter_set_sprite (s, 432, 435);
PS.action_set_bound_box (s, 0, 0, 320, 200);
PS.emitter_creation_mode (s, rmAllways, 0, 1, 10);
PS.emitter_set_velocity (s, 15, 20, 290, 320);
PS.action_add_force (s, ftConstant, 9.8, 0.0);
PS.emitter_set_position (s, ptBox, 0.0, 0.0, 320.0, 240.0);
PS.emitter_set_transparency (s, 45, 99);
PS.emitter_set_age (s, 0, 60);
}
if (effect==3) {//Explosion
int s;
s = PS.CreateSystem(350, false, dtBackground);
PS.emitter_set_sprite (s, 386, 388);
PS.emitter_creation_mode (s, rmNumberOfTimes, 1, 1, 350);
PS.action_set_bound_box (s, 0, 0, 640, 480);
PS.emitter_set_position (s, ptPoint, 80.0, 105.0);
PS.emitter_set_velocity (s, 10, 70, 0, 360);
PS.emitter_set_transparency (s, 20, 90);
PS.emitter_set_age (s, 200, 300);
PS.action_add_force (s, ftConstant, 0.0, 8.0);
}
}


//Inside a room's script I do this:

function room_Load() {
ParticleEffect(1);//Just once because the effect is already set to run constantly
}

//I use the following part of code to auto-remove particles when a room changes.
function on_event (EventType event, int data) {
if (event==eEventLeaveRoom) {
if ((data==11) || (data==23)|| (data==26)|| (data==36)|| (data==35)|| (data==34) || (data==28) || (data==19)) {// Rooms
while (PS.num_systems) {
PS.DeleteLastSystem();
}
}



Hope that helps a little.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

R4L

Thanks Dualnames. I'd rather not copy the code, because I'd like to figure it out myself and get back into coding, but it's confusing me too much. :)

Thanks again.

FrancoFranchi

Sorry for bumping an old thread, but does anyone have a mirror of this file (and the demo)?  Didn't realise AGS could do this and its given me some new inspirations.

Dualnames

#28
Not sure if I changed the demo or not. But here it as officially distributed:

http://www.mediafire.com/file/z3mtmy1wzhw/ParticleSystemManager.zip

EDIT: This is version 1.00 and not the last that Jerakeen distributed.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

cubehouse

I don't know what is up with this 2dadventures website, it's destroyed a load of plugins and modules.

Has anybody got the latest version? Or at least a clue how to fix the RawRestoreScreen() problem?

Calin Leafshade

i think you can actually just delete that line and everything still works

cubehouse

Quote from: Calin Leafshade on Mon 28/06/2010 18:16:06
i think you can actually just delete that line and everything still works

nah, it leaves trails of the particles behind - it needs to reload the original background before it redraws the particles on it (looks cool, but not my intended effect ;) )

cubehouse

#32
Ok, gave editing it a shot to update it to (I'm using 3.2, so can't confirm for other versions).

Basically, in the script, add this variable (below line "int num_systems;"):
Code: ags

DrawingSurface *orig;


Replace:
Code: ags

RawRestoreScreen ( );

With:
Code: ags

DrawingSurface *back = Room.GetDrawingSurfaceForBackground();
back.DrawSurface(orig);


Replace:
Code: ags

RawSaveScreen();

With:
Code: ags

orig = Room.GetDrawingSurfaceForBackground();
orig = orig.CreateCopy();

tzachs

Hi, this is an awesome module, with many functions, unfortunately it slowed down my character walk speed immensely so I won't be able to use it for my current game.

Anyways, just wanted to report what I believe to be a small bug.
In ParticlesSystem::Delete (), the following line should be added:
  num_sprites -= this.num_spr;

This will avoid crashing the game if it runs a lot of particle effects througout the game...

Joe

Quote from: tzachs on Mon 26/07/2010 22:34:57
unfortunately it slowed down my character walk speed immensely so I won't be able to use it for my current game.

I think if you activate the 'split resource files' option then your game won't slow that much.
Copinstar © Oficial Site

tzachs

Thanks for the suggestion, I tried 1Mb split, it may have improved a bit, I'm not quite sure, but it's still too slow...

AGD2

Sorry for the bump, but I was wondering if anyone knows how to get this module working so that the particle system gets drawn on to a dynamic sprite/drawing surface, which could then be displayed on a room object (so you could set baselines and have the particles disappear behind walkbehinds etc.)?

Sadly, even after implementing cubehouse's code in the above post, using s = PS.CreateSystem(300, false, dtSprite); will result in no particles showing up in the game. Any ideas? Thanks!

jerakeen

Hi, Right now i can't help with this. I don't remember  anything  about the module :sad:

in fact i hadn't read the whole post and i don't know if the old link is working, so here is the link to the last version i had.

Particle System Manager v0101

I hope it will useful to you.

i'm sorry i can't help.

bye

jerakeen

Pd. Give me some time, please, to upload again the examples and other files, and read and study them to see if i can help.
There was some time since i was in AGS world ...

AGD2

Excellent, thanks for the updated module, jerakeen! :)

Running this under the latest AGS 3.3.0 beta, there was an issue with all the particles being drawn as blue cups (default sprite) and it was also very slow. It was possible to work around this by replacing this line:

AllParticlesSystems[num_system].num_spr = max_slot - min_slot + 1;

With these two lines:

  AllParticlesSystems[num_system].num_spr = max_slot - min_slot;
  AllParticlesSystems[num_system].num_spr ++;


The included readme.txt file also brought my attention to the existence of this function:

QuoteDynamicSprite *GetSystemSprite (int system);

    Returns the sprite of the system if we draw on sprite or Overlay.
    We can use later this sprite in a Room's object so player can walk behind and
    in front of the system.

However, I can't figure out how to get that dynamic sprite showing on a room object. If I do this:

object[4].Graphic=PS.GetSystemSprite(s);

... it obviously doesn't work, so if you get a chance to look over it, that would be highly appreciated!

PS. The readme.txt also says " NOTE: Drawing particles transparent on a sprite or overlay doesn't work properly", but even if I set it to draw on dtSprite and set the particles transparency to 0, the particle system still doesn't visibly show in the game.


SMF spam blocked by CleanTalk