YTMC DevLog #2: Flooded with Tools

This is part two of my developer log on “Yeti’s Tile Map Creator”, an extension for the Unity game engine.


  • Tile eraser tool is now fully functional
  • Added flood-fill tool that lets you quickly fill an area with a pattern of multiple tiles
  • Created a utility class that can be used to quickly and conveniently add keyboard shortcuts to the Map Creator
  • Added a few keyboard shortcuts

The new tools


Let me try to make this sound super exciting: 

Holy sperm whale stuck on a pear tree! With the newly introduced eraser tool all your mistakes will be forgiven! Accidentally misplaced a tile? Unhappy with your creation? Feeling miserable about your recent life choices? Worry no more! YTMC’s eraser tool will wipe out all of your little screw-ups and help you make things right again. And it comes in many different sizes! The future is NOW!

All jokes aside, it lets you delete tiles. That’s about as exciting as it gets. To create this tool, all I had to do basically, was make some minor tweaks to the method responsible for placing tiles. Oh, and the eraser can be resized. Yea…


I added a tool I honestly wasn’t sure I would when I started developing YTMC. But after a few test drives I realized that a flood-fill/bucket tool was indispensable. 

Since I never had to deal with anything similar to implementing a flood-fill tool for what you could call an image processing software, I consulted the good ol’ internet to get an idea of what an efficient and memory saving algorithm for the job would look like. I quickly found myself on Wikipedia with a pretty straight-forward solution (pseudo-code ahead):


I didn’t expect the thing to be too complicated. But I was a little surprised it was going to be THAT simple. 

As always in programming, there are of course plenty of other ways to implement this feature. But I figured this one was the best option to go for.

A lot of other solutions are based on recursion, but I was looking for a way that takes up as little memory as possible. Considering how many recursive method calls the process would make, I didn’t want to take the risk to leave the user with a stack overflow exception when they try to flood-fill a larger area.

My adaptation of the algorithm was implemented really quickly. However, I wanted a tool that can fill an area with not just one tile repeatedly, but with a pattern of multiple tiles. So, I extended the algorithm to meet that requirement.

Being lazy for the lazy

I wanted to accelerate the workflow for the user even more by adding keyboard shortcuts to YTMC. So, I thought about a way of implementing hotkeys without messing with any of the code I had already written.

What I ended up doing was creating a utility class that contains a collection of all the hotkeys available. This way, it’s really easy and convenient for me and future users of the tool to add new keyboard shortcuts that trigger a specific functionality.

Let me give you a brief insight into the code to give you an idea of what I’m talking about. Obviously, the following C# code was simplified for demonstration purposes:

Here’s a rough draft of the Hotkey constructor:

public Hotkey(Modifier m, Key k, Action<MapCreator> a) {
	// some stuff

So now we can add hotkeys to the HotkeyList utility class like this:

private Hotkey[] hotkeys = new Hotkey[] {

	new Hotkey(control, escape, (mc) => { mc.DoStuff(); })


For the “Modifier” parameter we pass a representation of the modifier key (alt, control, shift etc.) that needs to be held down for the shortcut to be triggered. Knowing that, I reckon you can guess what we pass for the “Key” parameter. 

The fun part is the last parameter. Here we pass an anonymous method that is to be called when the key combination is pressed. In this simplified example, think of “mc” as being the main window of the Map Creator. We can now let our anonymous function use all the public members of the Map Creator window and its components. This way, we don’t have to make any changes to the Map Creator’s code itself. Also, we now have an excuse to make use of lambda expressions to show the world how cool and clever we are. Amirite? 😀

Up next

I guess, my next bigger step will be to add a collision editor to the Map Creator. I’ve planned it to be a visual tool that enables the user to simply add closed polylines to the map that will eventually be converted to Unity colliders. But we’ll see what I’ll end up doing exactly.

The visuals

To conclude this devLog entry, I’m gonna leave you with a few gifs to showcase the progress of YTMC:

Tileset used in these examples made by: Reemax



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s