December 31, 2019

Progress Update | Programmatic Auto-tiling

Starting a new project has been very interesting. I worked on The Last Librarian for two years, so I've practically forgotten what it's like to start a brand new project. It's a completely blank slate, and it's incredibly fun because of the experience I gained from the previous project. I am able to make so many improvements to even the most basic things.

So far, the only programming I've done is very basic engine things, but I am approaching a place where I might be able to start messing around with procedural generation. Here's what I've done so far:

  • Camera functions and screen scaling.
  • Player movement and object collisions.
  • Controller detection and input. (Set up to allow for control remapping).
  • New generation algorithms that handle auto-tiling.

The auto-tiling code is the most interesting part. This allows me to place tiles that connect seamlessly with adjacent tiles. The GMS2 room editor has auto-tiling functionality built-in, but as I wish to procedurally generate the terrain, I need to be able to do that myself programmatically. This algorithm I wrote is compatible with my older PGC library. (See GM Marketplace - Jen_scripts). Here is a GIF showing two iterations of a test room. The tiles are placed randomly and ran through the auto-tile algorithm.

I used bitmasking for most of the tile checks. Here is a more detailed article on the topic: Tile Bitmasking with Auto-tiling. Each position tests for adjacent tiles then chooses the appropriate tile index for the conditions. Bitmasking worked for the broad strokes, but I needed additional special cases to take care of corners and diagonal tiles. My solution also uses a default "invalid" tile, which is shown as the double squares in the GIF. A tileset artist for the game can decide to use that tile or leave it blank, depending on how it fits into the rest of the tileset.

I would show more images, but this is kind of all I've got. Stay tuned for more updates in the future.

No comments:

Post a Comment