Author Topic: MODULE: Akumayo's Particle Engine v1.5  (Read 13618 times)

Akumayo

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
MODULE: Akumayo's Particle Engine v1.5
« on: 02 May 2006, 00:27 »
(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
« Last Edit: 01 Jul 2006, 05:45 by "Acqua" Akumayo »
"Power is not a means - it is an end."

Scorpiorus

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: Akumayo's Particle Engine
« Reply #1 on: 02 May 2006, 02:22 »
Good work, nice looking effects there :)

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #2 on: 02 May 2006, 03:07 »
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.

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #3 on: 02 May 2006, 04:47 »
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

  • Truly Hated
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #4 on: 02 May 2006, 05:36 »
Thank you .

Akumayo

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #5 on: 02 May 2006, 23:09 »
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!
« Last Edit: 03 May 2006, 01:26 by "Nerezza Acqua" Akumayo »
"Power is not a means - it is an end."

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #6 on: 03 May 2006, 01:18 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #7 on: 03 May 2006, 01:20 »
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."

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #8 on: 03 May 2006, 01:31 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #9 on: 03 May 2006, 01:36 »
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."

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #10 on: 11 May 2006, 10:53 »
Is it possible for you to add a demo game, but with source code, so we can have a look at it?

Akumayo

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #11 on: 12 May 2006, 00:06 »
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."

Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #12 on: 17 May 2006, 10:51 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.0
« Reply #13 on: 20 May 2006, 07:54 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #14 on: 24 May 2006, 20:51 »
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

  • Truly Hated
Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #15 on: 24 May 2006, 21:32 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #16 on: 24 May 2006, 21:36 »
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

  • Truly Hated
Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #17 on: 24 May 2006, 21:51 »
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

  • Is Watching You
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with scripting
    • I can help with story design
    • I can help with voice acting
    • Akumayo worked on one or more games that won an AGS Award!
    •  
    • Akumayo worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #18 on: 24 May 2006, 21:57 »
Sorry, I forgot to mention, the Emit_Particles function has been renamed to Single_Emit_Particles.  That should fix your problem.
« Last Edit: 25 May 2006, 15:16 by strazer »
"Power is not a means - it is an end."

Re: MODULE: Akumayo's Particle Engine v1.5
« Reply #19 on: 26 May 2006, 17:04 »
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!