Cloning Loop-the-Game

I want to explore two things about this fascinating game: how it generates loops and how the game might be made even better. To do that, first I need a basic clone of the game.

Games Platform

The platform I know best is Unity, with code in C#. Earlier games such as Polygamo and Puzzlang provide a solid foundation, but they are based on a rectangular grid. Hexagonal grids are obviously quite different. You can fake a hex grid by pretending it’s rectangular and offsetting every alternate row, but the code gets messy fast. I know, I tried!

Unity provides an excellent platform for writing simple puzzle games. It’s really easy to attach bits of code to game objects and the code is simple and straightforward. Even better, the compiler code has been updated to the latest version so all the cute features of C# 4.x now work.

Hex Grid Library

The definitive reference for using hex grids in games is this article on Red Blob Games. It provides code in C#, which can be used as a starting point. First I tried each of the hex grid libraries referenced in the article, but I found that variously that they were:

  • very basic, lacking key features and particularly any kind of search algorithm
  • tightly coupled to Unity in ways that ruled out my kind of model-view
  • broken, just did not work at all.

So I decided it was time to just take the Red Blob code and get it working. I added a number of utility routines and two major pieces of functionality.

  • Path searching based on red-blob again. This includes A* search, which requires a Priority Queue: there is a nice one open-sourced by Microsoft.
  • Generic grid generation: hexagon, rectangle, parallelogram, triangle, etc. instead of the hard-coded loops provided by Red Blob.

It seems simple enough, but writing any kind of game requires attention to lots of detail. I decided to go with a 2D game using UI components like panels and sprites. So I need:

  • Assets: sprites for the grid, loops and buttons
  • Palette: to make nice colours
  • Font: the game is minimalist, but it still has some text
  • Animations: stuff needs to move!
  • Sound and Music can come later.

After wrestling too long with the Unity Animation system, I gave up and decided to go with a Tween library. I chose LeanTween, but there are others. And this is what it looks like, running in the Unity editor.

Creating the loops, now that’s the subject of another post!

This entry was posted in Arcopoly. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *