Jump to content


Air pressure

  • This topic is locked This topic is locked
3 replies to this topic

#1 chaz13


    GMC Member

  • GMC Member
  • 4214 posts
  • Version:Unknown

Posted 27 February 2012 - 12:04 AM


I'm working with a platformer game with a grid based system, all tiles and such lie on a 16x16 grid (and are destructible, terraria style). The idea is it's based on an alien planet and the player has to be careful about creating bases that have a solid air supply and such. Each cell in the grid is going to have an "air level" stored in a seperate ds_grid from the terrain one. There'll be objects that pump out air, and I want it to travel semi-realistically so it'll build up pressure in sealed off areas.

The player will need a basic pressure or air value in a grid cell to be able to breath, so by creating a sealed off base and creating objects to make air they'll be able to breath in their environment.

The problem is, how should I go about making these objects fill up the grid spaces around them with air? I was first considering looping through objects that do this and having loop propogating out in a flood fill fashion, but I'm not sure if that'd work so well. My other idea is to loop through each grid cell, and if it's got a higher pressure than surrounding cells move air into them. The issue with this is the speed, and also the fact that it'd travel too far from a source- I'd only want it to be able to pressurize say, 10 cells radius or whatever, but this system would have cells with tiny pressures all over, which is not really a huge problem but isn't a very neat solution.

Any thoughts?
  • 0

#2 YellowAfterlife


    GMC Member

  • Global Moderators
  • 4157 posts
  • Version:GM:Studio

Posted 27 February 2012 - 12:41 AM

Simple solution is to iterate through all grid cells, 'sending' 1 air to adjacent cells if they have less air. So yes, basically second solution. To achieve good performance this would also require using a data structure or a mini-dll to do time-consuming parts of operations.

Advanced solutions would mean to store maximum distance which air can travel... but hey, even real air doesn't work like that.

Edited by YellowAfterlife, 27 February 2012 - 12:42 AM.

  • 0
If my posts contain broken links, try looking around my website. I gradually make blog posts for any examples I make.

#3 Gamer3D


    Human* me = this;

  • GMC Member
  • 1819 posts
  • Version:GM:Studio

Posted 27 February 2012 - 03:55 AM

I think the key to doing this quickly will be detecting when an equilibrium is reached (or is close to being reached) in some area. Perhaps a quadtree storing minimum and maximum pressures in an area, and not updating it and its branches if the difference is small enough?
  • 0
Fast Priority Queues - Game Maker's priority queues are O(n). Mine do everything that Game Maker's do, but in O(log n) time.
Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.

#4 xot


    GMC Dismember

  • GMC Elder
  • 4785 posts
  • Version:GM:Studio

Posted 27 February 2012 - 07:50 PM

This article by Mick West might stimulate your brain.


Not sure GM by itself is up to the challenge, even with the trickiest code, but I haven't really looked into it since this article first appeared in Game Developer Magazine in 2007. Perhaps if your needs are modest a solution might be practical.

Ron Fedkiw (cited above) has done some cutting edge work with high speed CFD that you might find interesting.


This paper is a good place to start.

http://physbam.stanf...ford2010-02.pdf [PDF]
  • 0
GMLscripts.com, rise from your grave!

If any of my posts contain broken images or links, I can probably supply them for you. PM with a link to the post.