Omnimaga

General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Spyro543 on November 01, 2011, 04:49:01 pm

Title: Fluid simulation in Game Maker
Post by: Spyro543 on November 01, 2011, 04:49:01 pm
New Version 2 out. Click here (http://ourl.ca/13759/259807)

I made a very simple fluid simulation in Game Maker:

Link to video (http://www.youtube.com/watch?v=_GuJmUB8HO8)

Here's the source: http://anova.57o9.org/junk/fluid.gm81 (http://anova.57o9.org/junk/fluid.gm81)

The controls are: click to place a wall block, right click to release water, Shift to erase whatever is currently under the mouse, Delete to erase everything, and Enter to make a water pump that continually releases water.

The cellular automata rules are very simple:
1. If space to left empty: move left
2. If space to right empty: move right
3. If both left and right spaces are empty: randomly move either left or right
4. If space below empty: move down

Here's the code I used to simulate the water physics:
Code: [Select]
if position_empty(x,y+6)
{
y = y + 6;
exit
}
if position_empty(x+6,y) and position_empty(x-6,y)
{
randrange = irandom_range(1,2);
if randrange = 1 {x += 6};
if randrange = 2 {x -= 6};
exit
}
if position_empty(x+6,y)
{
x += 6
exit
}
if position_empty(x-6,y)
{
x -= 6
exit
}

I know I need to add a toolbar or a little box that shows the commands you can use in the next release. Besides this, any other suggestions or comments?
Title: Re: Fluid simulation in Game Maker
Post by: DJ Omnimaga on November 01, 2011, 08:40:21 pm
Looks pretty interesting.  I wonder how the speed compares with a calc equivalent? I unfortunately forgot where was located Builderboy's Axe version on the forums. XD Also to run the gm81 file do I need Game Maker installed? I wonder if you could make an exe file if that's the case?
Title: Re: Fluid simulation in Game Maker
Post by: Builderboy on November 01, 2011, 08:48:01 pm
Here it is DJ http://ourl.ca/4279/169816 :D It's part of the physics lessons tutorials.  And nice implementation!  It seems you stumbled upon the same set of rules that I used! ^^
Title: Re: Fluid simulation in Game Maker
Post by: DJ Omnimaga on November 01, 2011, 08:55:20 pm
Ah thanks :D. I like that kind of demo.
Title: Re: Fluid simulation in Game Maker
Post by: Spyro543 on November 02, 2011, 06:21:42 am
Here it is DJ http://ourl.ca/4279/169816 :D It's part of the physics lessons tutorials.  And nice implementation!  It seems you stumbled upon the same set of rules that I used! ^^
Yeah I actually used your cellular automata tutorials to make this ^_^
Title: Re: Fluid simulation in Game Maker
Post by: C0deH4cker on November 02, 2011, 10:13:30 am
I could compile it into an exe for ya. i have the full 8.1 version.
Title: Re: Fluid simulation in Game Maker
Post by: Spyro543 on November 03, 2011, 03:09:20 pm
I could compile it into an exe for ya. i have the full 8.1 version.
Thanks! For some reason, GM 8.1 won't accept my license I paid for...
Title: Re: Fluid simulation in Game Maker
Post by: Spyro543 on November 07, 2011, 06:10:07 pm
UPDATE!!! (v2)
Awesome updates!!!
Here's the new controls:

Here's a video for your enjoyment:


Source file: http://anova.57o9.org/junk/fluid.gm81 (http://anova.57o9.org/junk/fluid.gm81)
If anyone with GM 8.1 Pro could compile this, that would be great!
Title: Re: Fluid simulation in Game Maker
Post by: DJ Omnimaga on November 07, 2011, 06:38:54 pm
Isn't GM supposed to be free including for compiling? I saw many GM games being compiled using free versions before, the only difference being that no 3D was possible and there was a GM advertisement at the beginning when it was loading.

Btw this looks really nice. :D
Title: Re: Fluid simulation in Game Maker
Post by: collechess on November 07, 2011, 08:51:22 pm
Do you have plans for adding other particles?  And does the sand and water interact? e.g. Does the sand sink?  Also, you might find that making the particles larger might be better, as GM gets really slow when you add a lot of objects.  This does look really cool though.  ;)
Title: Re: Fluid simulation in Game Maker
Post by: imo_inx on December 06, 2011, 04:43:55 pm
Update: I guess I can help with it now. :P I added some new elements.

Changes:
Fazer added (allows particles to pass through for 1 second every 2 seconds)
Lava added
Bouncers added

I need help on the Lava+Water=Stone problem though, as "change object" and "create instance" don't seem to work.
Title: Re: Fluid simulation in Game Maker
Post by: JL235 on December 10, 2011, 09:34:40 am
I always love these, and as inspiration I cooked up my own version (much smaller) a week ago online here (http://www.playmycode.com/play/game/joe/blocky-sand).