3

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?

Anko
  • 13,393
  • 10
  • 54
  • 82
Zambonie
  • 53
  • 4
  • 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. – Anko Sep 28 '14 at 19:01
  • Thanks, for both that comment and editing (nearly my whole post) to make it more understandable. I was a little tired when writing that. – Zambonie Sep 29 '14 at 20:47

1 Answers1

2

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

House
  • 73,224
  • 17
  • 184
  • 273
  • 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. – Zambonie Sep 28 '14 at 15:41
  • Just wrap the functionality of loading, and selecting the correct version in a class, and you'll be alright :). – Roy T. Sep 28 '14 at 20:35