Loading [MathJax]/jax/output/HTML-CSS/jax.js

MatchWalker, a puzzle game of shape and colour


< change language

In today's post I will be sharing a game I made with just under 400 lines in Processing, a wrapper for Java that makes drawing to the screen really easy.

The goal of the game is really simple: go from the cell you are standing on (marked with the black outline of the ellipse, in the screenshot) to the cell that is framed in white. To do that, you can move a "cursor" (the black frame) with the AWSD keys to choose the next cell you want to go to. To move, press the space bar. There are a couple of rules to moving, though:
  1. You can only move to the selected cell if it is in the same row or same column as the cell you are in;
  2. You can only move to the selected cell if it has the same colour or the same shape as the cell you are in.

Rule number 1 says you can only go in the directions these orange arrows cover:


Rule number 2 says that, from the cells specified by the above rule, you can only go to the white circle, diamond or vertical ellipse (precisely because they are white) or to the orange horizontal ellipse, because it has the same shape as the cell you are in (a horizontal white ellipse).


With these rules in mind, one possible way to finish the puzzle from the screenshot would be to follow these arrows:


The path being: first you go down to the white diamond and then up to the orange diamond; after that you go right to the orange circle, up to the orange vertical ellipse and then left to your final destination, the orange square.

When a given target cell is giving you too much trouble, you can press Q to select a new target (i.e. the white frame chooses another cell for you to go to).

If any of you wants to contribute, there is one improvement I think could be made to the way the board is generated. As of now, I hard-coded four 3×3 pieces and whenever the game starts, I shuffle them into the four corners and then randomly rotate them, thus creating the illusion of having a "new, random board" every time you start:


The board can, however be created in another way: just randomly assign each piece to a position of the board and then use a simple algorithm like a breadth-first or depth-first search, to ensure the graph induced by the pieces is connected. If it is not, just shuffle everything again.

The code is hosted in my GitHub repo; feel free to fork the repo and fiddle with the code! If you manage to find a more elegant way to create the game board, just make a pull request! You can also find Windows and Linux executables here.

Play a bit and let me know what you think!

  - RGS

MatchWalker, a puzzle game of shape and colour MatchWalker, a puzzle game of shape and colour Reviewed by Unknown on September 16, 2018 Rating: 5

No comments:

Powered by Blogger.