Coding comp: Particle Systems [WINNER: AKUMAYO]

Started by Kweepa, Sun 09/04/2006 16:57:32

Previous topic - Next topic

Kweepa

OK, the theme this time round is:
Particle Systems

That's it really. I want to see swirling smoke, spraying water, flickering flames, and drifting leaves, if possible all through tweaking some parameters. It would be ideal if
- each system was rendered onto a texture that could then be used as an object (and so characters can walk around it).
- it was fully modularized, with a flashy demo game.
- the code was available separately for quick perusal. We don't get much judging in this competition so anything that makes it easier to judge is a good thing.
- you didn't ask any pointless questions in this thread. If there's anything you feel I've left out of this description, or anything you don't understand, use your good judgment and discretion to fill in the blanks.

I know this is quite similar to the earlier weather competition, but it has unique challenges that set it apart.

Here are the rules:
1. Must be open-source. We can hardly inspect your coding if we can't see it.
2. Must contain instructions for how to add to an existing game; this will obviously be easier if the scripting is done as a module.
3. Only use of the 3D, TCP/IP and maths plugins are allowed.
4. Must provide sample game using your code.
5. Team efforts are allowed, and you're probably expected to get help for sprites, etc from elsewhere.
6. As far as possible, entries will be judged on their scripting and gameplay rather than GFX, SFX, music, etc.
7. Winner will be decided by 1 week of voting at the end.

Competiton runs 9th April to 23rd April.
Then, a week of voting.

Have fun!
Steve
Still waiting for Purity of the Surf II

DoorKnobHandle

#1
May I present to you:

THE PARTICLE-MODULE
___________________________________

Newest image:

Demonstrating the "Ring of Fire" - one of the new presets!

Older images:

Slow, rising smoke or fog - realized with the particle module...


The interface of the demo application that comes with the module...

I just wrote this entry together this day. The module comes with a detailed manual, a complete demo game or application that let's you try stuff out yourself without the need to import the module into one of your projects. Additionally, the source code of the module is excessively commented out and explains in great detail how all this stuff works.

The Particle Module features this:

> Very simple to use, because the user really only needs to use two simple functions. One to setup the behaviour and appearance for the particles and one to spawn them. It doesn't get any easier!
> Endless possibilities - you can draw your own particle sprites and use them - together with the right values for gravity, speed, transparency and the other parameters everything is possible!
> Comes with a long and detailed manual describing how to implement the module into your AGS project and how to use the new features and functions this module brings.
> Heavily optimized performance-wise. Depending on the power of your machine, this module can draw thousands and thousands of particles at the same time (which improves effects such as very fine smoke).
> The demo game lets you test out new parameter settings for new effects very quickly. Just by shifting some sliders you can play around and try to come up with new interesting shapes etc. Additionally, you can save those settings as presets, then restore them later on or load some of the presets that come with the demo game to see what is possible. Of course, even the demo game is completely open-source, so that you can take learn how to use the module while taking a look at the sourcecode.

Just try it out - get version 1.0 HERE! UPDATED LINK!

Please leave any feedback, I hope I did everything correct - after all this is the first Coding Competition in which I am entering!

Kweepa

#2
Excellent - great start!
I hosted it here so you don't have to go through rapidshare to download it:
http://www.steporg.com/step/ags/comp/dkh/ParticleModule_DemoGame.zip
dkh, let me know when you've updated the module and I'll re-upload it.
[EDIT] Re-uploaded. Now the second version.
Still waiting for Purity of the Surf II

DoorKnobHandle

#3
Thanks for the comments and the hosting! I can't wait to see how other entries will work!

EDIT: I just managed to update the module and the demo game. Please take a look at the screenshot above and the new files...

SSH

For those of us without the time to look at the whole source, I'd love to hear an explanation of the technique you used, dkh, especially for speed optimisation.
12

R4L

Wow dkh, your module is fantastic! I love the smoke preset. This is most useful!

DoorKnobHandle

Thanks, Rap4Life!

SSH:

Allright, no problem. :) This is taken straight from the beginning of the modules source code:

Code: ags

// EXPLANATION

// this particle module works in a very easy, yet effective way: every particle has its own properties
// ( such as position, velocity etc. ) and will be called every frame in order to update its values.
// additionally a particle can be either active ( which means that it is currently somewhere on the 
// screen and in use ) or inactive ( which means that it is not at the screen or in use ).
// of course all particles are inactive in the beginning. once the user calls the 'spawn_particles'
// function to request a certain user-chosen amount of particles to a certain user-chosen point on the
// screen, the requested amount of particles will be marked active and thus be updated, drawn etc. every
// frame automatically. to make sure that we don't run out of free and inactive particles after a certain
// amount of them have turned active, we need to deactivate them again. thus, a particle is deactivated
// as soon as it is outside of the current screen ( for example when it falls through the floor ).


So, the module has one big array full of particles - the good part is that only active particles need to be processed and using a backward while-loop the module can always find any remaining particles. First of all this makes sure that only particles that are really on the screen are rendered currently and nothin more. Considering speed, of course the module works faster when the user doesn't use the blending/transperancy options, however you can still display up to 1000 blended particles which is really more than enough to symbolize quite realistic looking smoke etc. I can't think of any way of speeding the drawing process up more using AGS, but as I said before, would love to see new entries and how they approach this task.

Rocco

Unfortunatly i cant start the demo game nor test the sources.
i get this error in both cases:

Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x0045C87F ; program pointer is -195, ACI version 2.71.894, gtags (0,0)

have others also noticed this behavior?


DoorKnobHandle

That is very strange! I'll need CJ's help to interpret those numbers, I guess.

Well, Rap4Life could obviously run the demo game as well as Steve, I think.

Thanks for reporting, Rocco, I can't wait to find out what causes this!

Akumayo

It's been a long and tedious process, but there will be another entry now in this beautiful topic.Ã,  I love the idea Steve!Ã,  Now, after I used Wikipedia to actually find out WHAT a particle module was, I was very interested in making one.Ã,  May I present:

Akumayo's Particle Engine

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.

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
*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
Ã,  Ã,  Ã,  -Demo game of effects (.exe)

Ã,  Ã, -Effects Editor Demo
Ã,  Ã,  Ã,  -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.Ã,  (RTD)

Ã,  Ã, -Akumayo's Particle Engine (.scm) The module itsself.

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

Download the bulk file, which contains the stuff listed above (1.15 mb in size):

Akumayo's Particle Engine


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

I hope you enjoy it!

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

Akumayo

C'mon people!Ã,  It's the last day, surely there will be at least one more entry?

I despise only two entries, it means I can't vote, not really.Ã,  Neither can dkh, not really.Ã,  We can only vote for one another, and that is pointless... there had better at least be some interest in the voting/playing community!Ã,  I had better see votes from SSH, and Rap4Life42o, and Rocco, and Steve (of course)!Ã,  If I do not see votes, I will be very very... not angry but... dissapointed.. or something...


Okay, I'm done now, go back to your lives...Ã,   :P

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

Akumayo

Oooookay.... will at least you vote Steve?  It HAS been over two days since the deadline for entries... :-\
"Power is not a means - it is an end."

buloght


MarVelo

I will start the voting I guess...


My vote goes to Akumayo. He didnt even know what a particle module was and he created such coding. GREAT job.

Akumayo

I don't think the fact that I didn't know what a particle engine was should have anything to do with the voting, but I am definately not complaining!  Thanks for the comment anyhow.
"Power is not a means - it is an end."

MarVelo

I'm just saying that you made something so excellent from a starting of 0 knowledge. You're worthy of my vote.

R4L

My vote goes to dkh!  ;D Good job on that though...

Akumayo- i liked yours alot too, but I had to go with dkh cause his was easier to use and adjust.

Rocco

I vote for Akumayo.
You did a great job, and your system works very well.

dkh: as i wrote above, i never get your module or your compiled demo to work, so i couldnt say anything about it, sorry for that.

DoorKnobHandle

#18
Thanks for your vote, Rap4Life42o.

I really don't want to appear as a party-pisser, but I don't really think that it makes sense to vote if you couldn't test out both entries, Rocco. I personally don't care too much about the outcome of this contest and know that "participating" is everything and not winning, but since this is a contest with voting, we should keep it fair.

And you are the only one that can't get the module to work, there's pretty obviously no problem with my code, it's more likely to be a bug somewhere in AGS or your system configuration and beyond my possibility to fix.

Still, I appreciate your interest in this competition and that you tried both modules out and voted here, not a lot of people do this. :) So, no reason to take this personal or anything, this just my opinion on this matter.

Rocco

sorry dkh, 100% understand your point of view.
its not fair to vote without testing both entries, but i tried different things to start your module and demo without success, and akumayos entry is very good without question.
the coding competition have no big audience so i decided to vote, its a subjective thing, sorry.
steve should determine to count this vote in or not.

SMF spam blocked by CleanTalk