Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Particle demo

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Oct 2021 17:14
I do mostly JS development these days and came across this neat particle effect library and wondered how easy it would be to recreate. Staring at it for a minute it just looks like it matches to a nearest neighbor (kind of like voronoi tessellation). So here's my lunch break snippet. It'd look nicer with anti-aliasing. I suppose I could do this with sprites, wouldn't be too difficult.


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Oct 2021 18:19
purdy

kinda like watching constellations "dance"
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 19th Oct 2021 04:55
It looks like a screensaver. A bit hypnotic, I think.
I wonder what it would look like if the individual particles had mass and attracted each other accordingly. .
If two particles collide, the masses should add up.
Would it then be a simulation of the genesis? (just kidding)
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Oct 2021 18:47
I like the idea of weighted particles. Bigger ones could reach farther.

It occurred to me that this actually draws twice as many lines as necessary, because each of the connecting particles will draw a line to the other. So A draws to B but B will also see A within range and draw another line. Since there's no telling how many lines will be drawn from a particle I don't see an easy way to fix this short of having an array of children for each particle. But then trying to look up each particle to see if it's a child of another already might be even less efficient.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 21st Oct 2021 05:07 Edited at: 21st Oct 2021 17:46
Phaelax wrote: "It occurred to me that this actually draws twice as many lines as necessary, because each of the connecting particles will draw a line to the other. So A draws to B but B will also see A within range and draw another line. Since there's no telling how many lines will be drawn from a particle I don't see an easy way to fix this short of having an array of children for each particle. But then trying to look up each particle to see if it's a child of another already might be even less efficient."


I think I have the solution here, or at least an approach.
I have changed your code a little bit. So that now the determining and drawing of the lines happens recursively in a function.
I don't know if the result is the same. But it saves about half of the lines.
Original version around just over 600 lines.
Recursive version around 320 lines.



EDIT: OOps, The function is not called recursively at all. But it still saves lines.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Oct 2021 17:55
Nice. On mine it maxed at about 180fps, yours hit around 240. It might be higher, but right now I'm really taxing my cpu with a multi-threaded decryption program. I was actually thinking about using a flag last night as a possible solution. At first glance I'm still not sure how it works lol.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Oct 2021 21:34
Hehe, I just noticed that you only have to change two lines in your code. then it's faster than mine.

Change line 59 to
(not absolutely necessary)

Change line 68 to


Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2021 05:15 Edited at: 28th Oct 2021 05:17
Ahhh, you sir are a genius! It seems so obvious now. Now I peak at 320 fps. (my cpu is also taxed at 90% for 5 days straight now running decryption) Oops, back down to 280fps after making some other changes.

Particles will grow after colliding, the smaller one is destroyed. Each particle contains its own color. I've also attempted to fade the particles out as they near the edge of the screen, but there still seems to be some flicker right as they go off the edge.



Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-20 10:51:07
Your offset time is: 2024-04-20 10:51:07