# Hexic Match Checking

**URL:** https://forum.kirupa.com/t/hexic-match-checking/277827
**Category:** flash
**Created:** [December 17, 2008, 8:00pm UTC](https://forum.kirupa.com/t/hexic-match-checking/277827 "2008-12-17T20:00:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tperin](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@tperin](https://forum.kirupa.com/u/tperin)
#### Post date: [December 17, 2008, 8:00pm UTC](https://forum.kirupa.com/t/hexic-match-checking/277827/1 "2008-12-17T20:00:26Z")

</div>

Hey everyone,

First of all thank you all very much for your tips and tricks I’ve learned here. I have a dilema right now with a tile game, Hexic.

> **[Hexic](https://en.wikipedia.org/wiki/Hexic)**
>
> Hexic is a 2003 tile-matching puzzle video game developed by Carbonated Games for various platforms. In Hexic, the player tries to rotate hexagonal tiles to create certain patterns. The game is available on Windows, Xbox 360, Windows Phone, and the web. The game was designed by Alexey Pajitnov, best known as the creator of Tetris. While most earlier releases of the game were developed by Carbonated Games, the most recent version released for Windows and Windows Phone is developed by Other Ocean. ...

Currently, I have my pieces properly adding to the grid.

```auto
for (var a:Number=0; a<nTotalRows; a++) {
    gridArray.push(new Array() );
   }
   for (var A:Number=0; A<nTotalRows; A++) {
    for (var B:Number=0; B<colNum[A]; B++) {
     if (A%2!=0) {
      addPiece(A,B);
     } else {
      addPiece(A,B+0.5);
     }
    }
   }

```

The extra 0.5 in addPiece is an offset for every odd row. If it is odd, the pieces in that column will be offset by half in the y direction.

I am having some major trouble checking for matches of 3 or more. The problem I am having is that when the user clicks and changes the location, row and col of 3 different tiles, I don’t know the best method of checking for matches.

Originally I was checking the currentTile[row][col].type and comparing it to tiles in the above col, or below col, and if there were more than 3 of the same type I would push them to their own array. Vertical checking has been Okay because they vertical pieces do not have a X offset. The horizontal checking is messing me up because every second column is offset by half of a piece.

So, my grid is technically set up like this:

gridArray[row][col] … where row is 0 - 9 across and col is 0 - 9 (but depending on the row, the column is either whole number or decimal number (from the offset))…

Yea, it’s confusing. I would greatly appreciate if anyone could give me a little direction on how I should go about checking for matches in all 6 directions of each tile, or any tips.

Thanks in advance…
