I'm making a 2D sandbox game in C# and MonoGame, and I have a couple of tile sprites. These tile are loaded in-game as Texture2Ds. I want to have blocks visually connect to adjacent blocks.

An example:

This is how a tile would look if it was connected to another tile to its right side:

connected on right

Here's if all of its sides were connected:

connected on all sides

If none of its sides were connected at all:

unconnected, floating alone

I think you see the idea. Starbound and Terraria do a similar thing.

I don't want to have like 10 different textures for each block for every combination of every side, as that needlessly takes up space.

What can I do in the code to edit my existing sprites to look like this? Am I just better off going with 10 different textures? Or maybe there's something better I've missed?

  • \$\begingroup\$ Rocking first question! ★ I'd be interested in an answer that actually creates appropriate tile textures at runtime. Then you could even procedurally generate the tile sprites themselves. \$\endgroup\$
    – Anko
    Commented Sep 28, 2014 at 19:01
  • \$\begingroup\$ Thanks, for both that comment and editing (nearly my whole post) to make it more understandable. I was a little tired when writing that. \$\endgroup\$
    – Zambonie
    Commented Sep 29, 2014 at 20:47

1 Answer 1


Depending on the texture, if you're changing the texture based on orthogonal connections, you'll only need 5 (if the texture can be rotated) or as many as 15.

The simplest solution is to create these textures manually. You'll have a much easier time getting the visuals right.

As for deciding which to use, see this question and answer: Choose tile based on adjacent tiles

  • \$\begingroup\$ Ok, thanks. It will be a small pain to load these textures and manage them, but I will try my best to make this work out. Thanks again. \$\endgroup\$
    – Zambonie
    Commented Sep 28, 2014 at 15:41
  • \$\begingroup\$ Just wrap the functionality of loading, and selecting the correct version in a class, and you'll be alright :). \$\endgroup\$
    – Roy T.
    Commented Sep 28, 2014 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .