SpriteZ - 2d particle engine (Updated: June 15,2012)

Previous topic - Next topic

Hemlos

Thanks, i appreciate the thumbs up.
Have fun with it!  :good:
Bing ChatGpt is pretty smart :O

dman10001

Hi, I would like to know how I can make explosions using SpriteZ.

what are the values and what do I use?


Hemlos

#17
Put this in your header:

Code (HEADER) Select

numparts = 100 //partcle count max
lifetime= 1500 //1.5 seconds absolute lifetime per particle
SpriteZ = Emitter_Create_System( "media/Fire2.PNG" , numparts ,lifetime, FALSE)
Emitter_ColorAndAlpha( SpriteZ , RGB(255,128,0 ) , 1.0 )
Emitter_RadiusScalars( SpriteZ , 1.0 , 0.1 )
Emitter_Rotation_Velo( SpriteZ, 12 ) //twist 12 degrees per frame
Emitter_Nozzle_Spread( SpriteZ, 360 )

That will make your sprite emitter: Shrink, rotate, Spread 360, colored yellow, and bright alpha.
Dont forget to put a sprite for the emitter in the app_directory/media/Fire2.PNG/   
Anything 32x32 size would be good.



Now you need to have some kind of velocity in the loop, and you need to show it each loop:

Code (MAIN LOOP) Select
MOUSESTATE MX,MY,MB1,MB2
Velocity=0.05 // 0.1=low velocity 1.0=very strong velocity
Emitter_Velocities_XY( SpriteZ , Velocity, Velocity )
Emitter_Pause_Emitter( SpriteZ , 1-MB1 )
Emitter_Show_Emission( SpriteZ , MX, MY )


The left mouse button should trigger an explosion, it will create particle as long as you are holding it.

There are many options, and really the only way to make it exactly how you need it, you must do some experimenting.
If you need the particles to do something else specific, just ask.


PS. You need to create your own timer, to explode for a specific amount of time. The lifetime timer for Spritez is only for the lifetime of the particles which are rendered....not for how long the emitter is running for, for this you need to make your own custom timer...use the pause feature to turn it on an off for best looking results.

PPS. increase program performance with a second custom timer, using a timer with the above code: the timer should stop calling the Emitter_Show_Emission, 1.5 seconds(to match particle 'lifetime' set in header)  after releasing the mouse button. The just an example, i didnt provide this in the API. As you are the programmer, you must control exactly when and where the emitter is used of course.


Here is a screenshot of the above emitter:


[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

dman10001

Hi, Thanks very much. It worked perfect. Just one thing the game slows down when its called
I tried to adjust a timer, but the particles don't last long enough.


Hemlos

1. what size image are you using? (i recommend 32x32 or smaller, and triangle mode will increase perf)
2. how many particles? (i recommend very small amount <100 )

Tip 1: You must make sure you initialize ALL emitters one time! Init in the header only, before all loops.
So in other words, for each style of explosion(Bombs, Smoke, Fire, etc), you must initialize them all, before your main rendering loops.

Tip 2: Using more than 1 Emitter_Show_Emission, per render loop will significantly reduce performance, if you need  multiple explosions, just change the explosion position...the particles previously emitted will continue to live thier lifetime on the path they were already on.
Bing ChatGpt is pretty smart :O

MrTAToad

Wondering if it would be possible to update this to use extended types and what not...

Hemlos

#21
Good question toad.  :x
To be honest, i really dont know where to begin with a conversion.
If i had started in types in the first place...that would have been so much easier.

If anyone feels like optimizing the code, be my guest.. if it works the same way i intended, ill update the download with it.   :whistle:
As i understand it, there is plenty of room for improvement of the original code, without trying to convert dimensions to type.

Edit: i will also accredit you in the header for your work on optimizations.

Has anyone published anything using this api?
As of yet(as far as i know), no programs exist using it yet.
It has been a long time since i began the project, im so curious to see the code in action.
I would LOVE to see SpriteZ in action!
Bing ChatGpt is pretty smart :O

Hemlos

New stuff in the api...download is in the top message.
Many options are updated for easier to use.
A new option is in, FRICTION
And 4 working samples....this has been lacking i know.

Im going to continue to make a few more samples(theyll be separate from the main download, and in thier own messages in this thread(below)).
Bing ChatGpt is pretty smart :O

mentalthink

 :nw: :nw: :nw:

Hemlos this new API it´s awesome... perhaps I include in my game whit your permission, becuase the effects are awesoming, the gravity effect it´s like water... I don´t know if in Mobile devices de Fps drops down a lot, but this code it´s absolutetly very advacen, at least for me... this maths are very interesting...

Thanks a lot, and a PERFECT JOB!!!

Hemlos

The math...is a monster.
Of course you may use the API.
Let me know when you finish your program, i would love to see it.
Bing ChatGpt is pretty smart :O

kaotiklabs

Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Hemlos

Demo for Friction here..
No source, executable only...too many changes to engine, must wait.
Basically what i did was increase emitter_friction() in the sample_gravity.gbap source...and remove emitter_gravity().


[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

Hemlos

What do you guys think about this..

optional function to limit the distance a particle goes, as opposed to using a lifetime?
Bing ChatGpt is pretty smart :O

erico

To me, the idea means an extended controller to it, to the point it could do a lot more then the original purpose! :good:

Hemlos

Something is brewing in SpriteZ land.
I am working on an experimental project, PointsGL, PGL sound ok?
Operation inject SpriteZ with steroids... multiply speed by 10.

Preliminary 3d rendering test:
60ms fixed particle movement rate
150,000 particles
screen resolution: 1280x720

On my junky video card...60fps!


Note: this is not the same way spritez renders...it is 3d.
Give this bin a whirl, test this bin.
Let me know the fps you get, and does it looks good or not, please.
http://www.glbasic.com/forum/index.php?action=dlattach;topic=3550.0;attach=5088



[attachment deleted by admin]
Bing ChatGpt is pretty smart :O