x


Best way to handle large, tile-based 2D worlds with arbitrarily removable tiles?

Hi, I am more or less trying to make a Terraria-like proof of concept.

That is, the player will move around in a large, rectangular (512 * 64 uniformly sized tiles) 2D world that has been completely generated before hand (that is the easy part), and will be able to remove tiles pretty much arbitrarily. I should note I am not concerned with making stranded tiles be affected by gravity.

If the world were static, it would be a simple matter of grouping rectangles of identical tiles together in a single plane, tiling the texture appropriately, and creating colliders for the resulting rectangles that are "exposed to the air".

If it's implemented this way though, for any tile that gets removed, all rectangle the tile was a part of will have to be destroyed and recalculated along with colliders to compensate for the newly created gap.

This seems pretty ineffective, and a bit dirty to be honest.

Is there an cleaner or more effective way to set up and/or remove these tiles and generate an appropriately sized collider for the resulting hole?

If it matters, I store where the tiles should go in a 2D array of ints, with 0 representing no tile and >0 representing the various types (which are simply different textures).

more ▼

asked Sep 17 '11 at 07:12 PM

dietclnp gravatar image

dietclnp
1 2 2 3

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1040
x374
x10

asked: Sep 17 '11 at 07:12 PM

Seen: 1004 times

Last Updated: Sep 17 '11 at 07:12 PM