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!


SMF spam blocked by CleanTalk