Jump to content
  • Advertisement
suliman

Simple physics for mine shaft game?

Recommended Posts

Hi!

Im planning a game where part of it is mining a vertical mine in a 2D side-view (similar to the pic below from pocket mine 2).

The ground is composed of distinct tiles (at least this is my first idea) of different material. How to deal with:

  • Tiles/ground should collapse (fall down/crumble to the ground) if not enough support is added. You can add wooden support in "tunnels" to keep the ceiling up. Otherwise tiles support each other if you dont dig to aggressivly.
  • Crubled tiles should "fill" the terrain where they fall.
  • I might include water (from underground pockets) that will sip into the mine and possibly drown the player. This could be simplified as filling "line per line" starting from the bottom until the volume of "loose water" is all deposited on the ground. Or more realistic physics.

Preferably i'd like some "ready to use" toolkit/library (for c++) that can achieve this without too much work for a physics newbie. Tiles/terrain types should have characteristics like "integrity"/strength or similar so that sand collapses easier than dirt (or rock). Or if this can be achieved with some simple technique that I can code myself :)

Any ideas?

 

Image result for Pocket Mine 2

Edited by suliman

Share this post


Link to post
Share on other sites
Advertisement

Sounds as simple as: a tile with support has 100% stability, the tile next to it has 100-materialStability, the next one has 100-2*materialStability and so on. You determine a cutoff (say, a tile with stability under 40% will cause a cave-in). When you add supports, recalculate the "distance to closest supported tile" for each tile and you're done.

Share this post


Link to post
Share on other sites

And then convert a tile to an object which I can accelerate. When it hits the ground convert it back to a tile? 

Or just have all tiles as "objects" all the time, just dont accelerate it downwards unless it's "loose". That might work.

But then all tiles can only fall straight down. It may feel pretty rigid :). Also does stability work like that? I mean a simplification is fine but will it seem realistic enough? I guess I can add more logic to it like each connected tile gives +X stability so loosely hanging tiles are more prone to "become falling".

Edited by suliman

Share this post


Link to post
Share on other sites
3 hours ago, suliman said:

Preferably i'd like some "ready to use" toolkit/library (for c++) that can achieve this without too much work for a physics newbie.

Box2D is a decent 2D physics library that is quite easy to use: You define some shapes (e.g. a circle), attach them to a 'body', configure physical properties such as mass, bounciness, etc and add the body into the box2d 'world' and update the world every tick of your game loop. The library takes care of calculating the physics, you just have to read out the X,Y positions of the physical bodies and position your sprites accordingly.

As you'll see from their website it's for simulating true(ish) physics, so if you're looking for something more tile-like then it's probably not the right choice and in that case I suspect you'll have to write something yourself.

 

1 hour ago, kseh said:

dMatter wrote an article about how he did fluid effects for his Week of Awesome entry last year that might give you some ideas.

Somehow that was way back in 2017, only feels like yesterday!

That was done just using Box2D and lots of tiny particle-like bodies. For higher performance & more realism Google have a modified version of Box2D called LiquidFun which looks cool.

Edited by dmatter

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!