MODULE: Akumayo's Particle Engine v1.5

Started by Akumayo, Tue 02/05/2006 00:27:12

Previous topic - Next topic

Akumayo

(This was the winner of the Particle Engine coding competition.)

This engine centers around the rendering of realistic-looking fire and smoke effects.Ã,  I've also managed to make it draw some water-based effects, and I'm sure that the end user, with some tinkering, can make even better and more diverse effects than I have managed.

Updates so far:

Version 1.5:
Ã,  -Added the ability to spawn particles continuously, rather than having to call the emision from repeatedly_excecute every time
Ã,  -User can now define how many particles to emit, rather than always having to emit all available particles
Ã,  -Cleaned up some minor errors and re-wrote the commentary

Some screenshots:

'Torch Flame' from the demo game:


'Rising Smoke' from the demo game:


'Falling Water' from the editor interface demo:


'Rising Fire' from the editor interface demo:


--------------------

Notable Features:

*User can define how many particles to render, so that different systems can render more or less particles
*Every part of the particle movement can be customized, so no two effects have to have anything in common
*Particles have the ability to 'fadeout' as they move across the screen, making fire/smoke far more realistic than particles that have a static transparency
*Changeable X and Y gravity allow particles to fall sideways, up, down, and at almost any angle
*Particles can be emited continuously by a function, for easier user-control
*Number of particles to emit can be defined
*The entire module is commented, so that the user can better understand how it works
*The .rtd that comes with the download details every function in full, and offers examples of how to implement each one
*Editor Interface Demo allows the user to play around with the module without having to upload it to a game, and lets them tinker with every variable that the particles use.
*Effects Demo lets the user jump right in and see five of the effects in action (geyser, rising smoke, campfire, torchfire, and waterfall)
*By tinkering with the variables, the user can make fire/smoke for every occasion, water effects, and beyond!

--------------------

Now, a brief overview of how it works:

Akumayo's Particle Engine works by emitting particles at a user-specified point, and giving them user-specified stats that control how they behave.Ã,  The particle transparency values can change by the fadeout value, so that things like fire and smoke can get more transparent as they reach the end of their lifespan.Ã,  The particles' speed counteracts gravitational forces acting on them, so a higher speed makes a particle more independent.Ã,  The particles' speeds will drop though, as they succumb to gravity, and then they will fall/rise accordingly.Ã,  The particles' ability to deviate gives them a more natural look.Ã,  Deviation on one axis or another can be the difference between a flat column of fire, and a roaring blaze.Ã,  A user-defined lifespan can remove particles after they have been on the screen for a while, allowing flames/smoke to disappear after rising on the screen for a bit.Ã,  They can also be removed by crossing user-defined x and y lines on the screen.Ã,  By default these values are the edges of the screen, but for effects such as waterfall, the particles would need to disappear as they hit the water, rather than when they left the screen.Ã,  When Emit_Particles is called, all inactive (dead) particles are placed on the screen at the user-defined coordinates, with the user-defined stats, and begin to move about.Ã,  Combining all these variables and stats together, realistic looking bodies of particles can be rendered in your game with the tinkering of a few functions.

--------------------

The download features:
-Akumayos Particle Engine Bulk File

Ã,  Ã, -Effects Demo Game (Uses V1.0)
Ã,  Ã,  Ã,  -Demo game of effects (.exe)

Ã,  Ã, -Effects Editor Demo (Uses V1.0)
Ã,  Ã,  Ã,  -A nice little editor that lets you create and test effects without having to code them (.exe)

Ã,  Ã, -Akumayo's Particle Engine Documentation, a help file containing information about all the functions that come in the module, and how to use them together to make effects (.rtf)

Ã,  Ã, -Effects Demo Sourcecode (Uses V1.0), the sourcecode of the Effects Demo game.Ã,  This will allow the user to view the way the effects in the demo were generated.

Ã,  Ã, -Akumayo's Particle Engine V1.5(.scm) The module itself.

--------------------

User Experience Recommended:
-Basic understanding of the RawDraw commands, especially RawSaveScreen()
-Basic understanding of how the sprite manager works

Advanced User Experience Recommended:
-Understanding of how the module works, by reading the comments within it

Download Here (2.7 Mb when unzipped) Contains all the stuff listed above

(Mirrors removed because the last upload was slightly corrupted, this has been repaired in the download above)

--------------------

I hope you enjoy it!

-Regards, Akumayo
"Power is not a means - it is an end."

Scorpiorus

Good work, nice looking effects there :)

strazer

Haven't tried it yet, but looks good. Nice work!

A few comments:

- The /*/'s you enclose the introductory comment with make it not compile in AGS v2.70. Using just /* and */ fixes that. Don't know if it would actually work there, though.
- Since you don't use the "Particle" struct outside of the module script, I don't see a reason to make it public and put in the module header. You can leave it in the module script if you don't need it elsewhere.
- By using static functions you can group all functions together and make the module more usable: Using a struct like
  struct AkumayosParticles {
    import static function Remove_All_Particles(...
    //...and so on
  }
  would show the user all available functions once he types "AkumayosParticles."
  Additionally, you wouldn't reserve any global names other than the name of the struct.

Dr. Scary

I messed around with this a bit, and I ran into a problem.
Each frame of the effect got drawn on top of the other and when I quit the game I got the "Error with RawRestoreScreen, Screen not saved" thingy. Had to add a RawSaveScreen myself in the room script. It should be an easy fix in the script. :)

Candle


Akumayo

#5
Strazer-Ã,  Thanks for the help, I wasn't sure how to group functions, now I know!Ã,  (I only put the Particles in the header so I could grab them from a pop-up menue)Ã,  I'll get on it soon.  (Thanks for re-vamping my post)

Dr. Scary-Ã,  I believe I mentioned it only in the .rtf file that came with the module, sorry.Ã,  You need to call "RawSaveScreen()" from your room script (probably in Player Enters Screen After fadein) in order for the engine to restore the original background before continuing with the effect.Ã,  Sorry for my lack of clarity on the matter.

Candle-Ã,  You're welcome!
"Power is not a means - it is an end."

Dr. Scary

uhh... DOH!

Sorry... :)


Nifty little engine, I must say. I was also wondering if it would be possible to make the gravity parameters into floats so it's possible to adjust the angle of the particle stream more accurately.

Akumayo

I suppose it wouldn't be difficult to implement float based gravity.  That would allow for things to be more accurate eh?  Would it be more worthwhile on the user-end, do you think?
"Power is not a means - it is an end."

Dr. Scary

Well... I was thinking of using it for a flamethrower (you know, just for fun :) ), but if the enemy is standing further down on the screen you can't really adjust the stream to the correct angle without going up to insane x and y gravities. Alternately you could just have gravity and angle as parameters.

Akumayo

So simply changing the values to floats wouldn't directly solve anything then.  Perhaps in a later version, I will try implementing an angle parameter.  Thanks for the suggestion, at any rate.
"Power is not a means - it is an end."

tiagocorreia

Is it possible for you to add a demo game, but with source code, so we can have a look at it?

Akumayo

Request granted.  The sourcecode of the Effects Demo game has been added to the file download linked in the first post.

-Regards, Akumayo
"Power is not a means - it is an end."

tiagocorreia

I've tried to emit particles using the repeatedly_execute_always, in a room. But that didn't work out. It works has the repeatedly_execute.
Any way to solve this problem?

I would also need this to solve problems with cutscenes. I know I can solve them, by keep calling the fucntions to emeit particles, but that is not very pratical.

Akumayo

I've never called the functions in repeatedly_excecute_always before, so I don't know how they behave.Ã,  I think they should keep running, but as I said, I haven't actually tried.Ã,  As for having to run the function over and over, perhaps, for now, you could set up a variable like Is_Cutscene_Going in your room script, and make it true when you start the cutscene.Ã,  Then run a check in the room's repeatedly_excecute to see if the variable is true, and if it is, Emit the particles.

In version 2.0 I will change the system of emmision so that the user has only to call a function to start/stop emmision from the present spawnpoint.Ã,  That way, repeatedly_excecute functions won't be relied on so heavily.Ã,  Thanks for pointing out that problem.

-Regards, Akumayo
"Power is not a means - it is an end."

Akumayo

Updated to version 1.5

Now it allows to call Continuous emmision, and define how many particles are to be used.
"Power is not a means - it is an end."

Candle

Going to try and make it work for me as I'm still trying to understand how to use it.
What I want to do is have a spot that will have smoke coming from it when you go into the room not when you click on something so not sure how to set it up.

Akumayo

Try this:

In Player Enters Screen (before fadein):

-Use Edit_Particle_Values to set up the smoke
-Call Continuous_Emit_Particles_Go to start up the smoke.

You may want to call it in (after fadein), if it gives you any trouble.
"Power is not a means - it is an end."

Candle

When I save the room I get this error
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:

In: 'Room 71 script'



Error (line 21): Undefined token 'Emit_Particles'



Do you want to fix the script now? (Your room has not been saved).
---------------------------
Yes   No   
---------------------------

Akumayo

#18
Sorry, I forgot to mention, the Emit_Particles function has been renamed to Single_Emit_Particles.  That should fix your problem.
"Power is not a means - it is an end."

tiagocorreia

It works great now.

I've changed to repeatedly_excecute_always, and it is great since like this it works during dialogs.

I'm putting a screenshot where I use.
Screenshot

Great job!


Akumayo

Hey, even I didn't know that it would keep running during dialogue, that's pretty cool.  I'm glad you're happy with it!
"Power is not a means - it is an end."

Rocco

i want to play a bit with this module, but most of the files in the zip are passwordprotected  :'(

Akumayo

#22
Really?Ã,  I'll have to look into that, they shouldn't be...

EDIT:

Checked, I was never prompted for a password, I downloaded and unzipped without problems.  What exactly is happening?
"Power is not a means - it is an end."

Rocco

when i klick extracting the files comes ->
the file "effect demo game_v10" is protected with a password,
please fill in that password.
then i press  - leave that file out
and then comes
the file "acsetup.cfg" is passwordprotected,
....
this goes on for almost all files
except the A_PE_V1_5.scm module itself, so i can use it but without examples or documentation.

i tried to open this file with the windwos xp inbuilt zip-extraktor

Rocco

i used 7-zip now and get the whole thing uncompressed without troubles.

Ali

This is a great module, thanks Akumayo!

Like tiagocorreia, I changed the module to repeatedly_execute_always. I also added an 'IsGamePaused' so that the particle engine pauses at the same time as object and character animations.

I found that skipping cutscenes and skipping-UntilCharacterStops was significantly slower with the repeatedly_execute_always change, even in rooms with no particle effects so I added a boolean variable to switch the whole thing off and on, so now skipping is only slow while particle effects are happening.

It thought I'd mention this in case it was in some way foolish, or in case you might consider adding similar features to the module.

WackyWildCard

Quote from: The Mighty Anglerfish on Wed 03/05/2006 01:20:44
I suppose it wouldn't be difficult to implement float based gravity.  That would allow for things to be more accurate eh?  Would it be more worthwhile on the user-end, do you think?

This is such an awesome module, but it would really help to have directional controls on fire effects - me especially, in my Game in Development, Knight's Quest: Shield Search. In this game there will be at leaset 2 Fire-Breathing Dragons. A special effect where the monsters can spit fire at the hero would be real icing on the cake!

Please let me know when the update is made! Thanks!


Akumayo

Egh, I'd love to get this updated, I really would, but don't expect anything anytime soon.  School and social life consume my waking hours.
This summer, perhaps, you can hope to begin hearing from me again.  Maybe I'll get this updated, work on a new game (still non-adventure, woo!), and re-join the community.  For now though, Akumayo is dormant as The Mighty Angerlfish.
Some day, friends, I -will- return.

-Regards, The Mighty Anglerfish
"Power is not a means - it is an end."

.M.M.

#28
Could you update your module for AGS 3.0? It is really great, but now I have 3.0 and it don't want to work.  :'(

m0ds

I've finally got my head around it, great module Akumayo!

One question though, is there anyway to make sure the particles appear "in front" of my character and other objects?

Many thanks!

SSH

It would be possible to adapt the engine to draw on an overlay or GUI instead of on the background. However, it would not be possible to do this with transparency unless you are running in 32-bit colour mode with an alpha channel.
12

Dusk

I was fighting with the same issue some days ago... the Lake module gave me the idea of using the I-don't-remember-now-the-name function to get the completely rendered frame (what you normally do to save savegame screenshots) instead of the background, and drawing on that the particles.
But I haven't tested this for now, there might be other issues...

For example, a problem that I had with the Lake module itself, was that the lakes reflect the cursor too... (lol)
It would be nice to discuss workarounds for this kind of issues, and if needed to ask CJ for little modifications in the engine to avoid the problems

Just my 2 cents,
D.

Dualnames

I'll post on of these days my APE(Advanced Physics Engine) script/module. Based on lake and particle engine it renders many things as well as explosions and other stuff. In the new hhgtg you can check it out. But you have to lose, in order to see it.:P
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)

Dusk

Interesting! How did you solve the cursor issue?

Dualnames

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)

Dusk

Quote from: Dualnames on Sun 06/04/2008 22:26:08
It's a kind of magic..

PRRRR, like disabling the the cursor graphic and handling it too with rawdrawing? :P  :P  :P

Seriously talking, are you going to release your module in the near future or do you prefer to keep it for you for now?

I have to decide if it's better to spend time fixing these issues or work on other ones.  ::)

an optimizing Dusk

Dualnames

I'm not planning to brag about it and never post it. I just have to fix it around since it tends to create magical weirdness all over.
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)

Dusk

Ehehe I see... well good luck with it, I'll check it out for sure when you're done.

Bye!
D.

SMF spam blocked by CleanTalk