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.

Code Snippets / [DBP] - Gas Physics Simulator

Author
Message
Rapidrory
14
Years of Service
User Offline
Joined: 21st Aug 2009
Location:
Posted: 1st Apr 2012 22:20 Edited at: 2nd Apr 2012 12:39
This is a simple gas physics engine that's supposed to simulate an 'ideal' gas. It looks ok, but the physics don't quite match reality in certain places. Still, not too bad for just over 150 lines...

I've added comments in case you want to use it in say, a virtual wind tunnel or some other simulator.

But for now its just fun throwing random particles at each other to see what happens

Left mouseclick to heat particles under mouse
Right mouseclick to cool particles under mouse
Spacekey+Mouseclick to grab particles and move them around
Returnkey to resize box to the mouse pointer
Mouse Wheel to change the size of the mouse pointer
Ctrl key displays particles according to velocity
Shift key displays particles according to temperature

(Advanced2D Plugin used. If you don't have it, get it here: http://forum.thegamecreators.com/?m=forum_view&t=179096&b=5)



EDIT: The code's been tidied up so it runs about 5 times faster. I get about 5 FPS when simulating 100000 particles

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Apr 2012 08:49
Interesting... but what is a2?

Hi!!!

Rapidrory
14
Years of Service
User Offline
Joined: 21st Aug 2009
Location:
Posted: 2nd Apr 2012 11:05
I've put it's full name now

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Apr 2012 11:33
I thought so if you put A2d or a2D or a2d no problem lol but still better in Full, come on no lazy coding ^^

perhaps your next move... link to the Advanced2D plugin forum page too?
just helps all the beginners, and makes for a sensicle forum

Rapidrory
14
Years of Service
User Offline
Joined: 21st Aug 2009
Location:
Posted: 2nd Apr 2012 12:39
Good plan!

I've also added an updated version which runs much faster (although the physics are slightly different now, can't tell if they're better or worse, but definitely faster )

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Apr 2012 13:34


noobnerd
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 3rd Apr 2012 23:45
cool, especially when the temperautre is low. when its like > 1000 it all looks like a mess ( like a gas )
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Apr 2012 19:13
Nice snippet!

Had to mess around with it - too cool not to experiment with, demo attached.

Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
Rapidrory
14
Years of Service
User Offline
Joined: 21st Aug 2009
Location:
Posted: 5th Apr 2012 21:03
Yeah, I originally wrote this to be a virtual wind tunnel, but getting it to realistically interact with an object turned out to be very difficult. I just ended up just playing with the gas for hours

@ Van B

Oh very nice! I had a go at adding trails to (based on velocity) but they weren't nearly as cool as your ones


Login to post a reply

Server time is: 2024-04-24 20:03:16
Your offset time is: 2024-04-24 20:03:16