Click here to Skip to main content
12,552,952 members (56,850 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked

HexaLines - original strategy puzzle game

, 29 Nov 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
New version of the popular game, with multitouch support


HexaLines is an original strategy puzzle game. I started to work on it more than three years ago (June 2009). One year later it was released for old Windows Mobile phones. The game had a very simple graphics, but very good replayability. It became a very popular (taking into account the smallness of that platform), in July 2010 it was the 4th best selling app/game on the PocketGear! 

But it took a very long time to rewrite this game to another platforms. The game was written in C# and .NET Compact Framework, but all the graphics stuff was made by standad GDI draw calls (functions like DrawLine, or FillPolygon). The whole game was composed only of lines and other vector objects, there were some simple animations, but not many.

New Version of the Game

A few months ago I have desided to refresh the graphics and vitalize the game idea. I have selected the XNA Framework as a new technology. I had previous experience with it and I hoped it will be easy to port this game to other platforms using the project MonoGame.

Actually we are finishing a final version of this game (my brother Josef helped me with the graphics). The first version is already available in the Windows 8 "Metro" Store. It provides a solid gaming experience, although many desired features are still missing (online score, other game modes...).  

The game is not available for desktop PCs yet, neither for Windows Phones nor other platforms. We wanted to finalize some things like an implement autosave, or an ability to "step back" in the game.

Possible Improvements

We hope that the desktop version could be completed in a short time. It would definitely need some refinements, but not so much. It would be very nice to have a multitouch support in this game - on the touchscreen, as well as on the multitouch touchpad. Pinch-to-zoom gesture would zoom with the plan, drag&drop with two fingers would move with the plan. Simple drag gesture will be for rotating cells. 

Another very interesting thing would be an accelerometer/gyro support. Shadows under the cells would move in a direction as you tilted the device (so it would look very nice and pseudo-3D). We could even add some GPS enabled game mechanics, or online multiplayer to this game. And we didn't even think about NFC yet! The test device would really help us (we don't have a tablet yet, or any device with the touchscreen - that one on the photos was only lent to us for a few days). 

And of course, the most interesting part for us would be an ability to submit this game into Intel AppUp store and the possibility to sell the game there!

Game Rules

So, what does this whole game is about? The game rules look complicated, but they are not. Every user could find an interactive tutorial inside the game.

HexaLines is a 2D strategic game for one to three players. You can play it against the computer or your friends. Players place hexagonal cells on the plan. From the center cell - three colors flow. Your aim is to fill up as many inner paths as possible with your color. The longest path wins... You see your score in a right bottom corner, as well as the next cell in the game (like in a Tetris game).

Players take alternate moves. Every move you can add a new cell on the plan, or rotate with some. Every cell has a colored or gray background (you can rotate only with cells with the same background as your color, or with a neutral gray ones).

Players can also harm each other :) If you pour over a color into another color, it will destroy the consequential cell. If you pour over a color directly into opponent's source, it will eliminate him. The game ends when the whole plan is filled with cells, or if the only one player survived. 

It is a very nice action game, if the player doesn't keep an eye on his cells, he can quickly lost. On the other hand - even losing player can turn the game into his win! The game contains elements of building, protecting, competing and also attacking. You can take a look on the gameplay video (not a final version of the game yet):

Gameplay video:


This game has also a very interesting implementation :) Every cell consists of several bitmap layers (background, the borders, reflections) and also of some "vector" layers. The inner lines are composed of many small triangles, they are generated dynamically in the game.

For the performance optimization, all bitmap parts of the cells are baked in the one bigger texture (spritesheet). Communication with the GPU is faster, because we don't need to send multiple textures in every frame, only that one.

Porting to desktop Windows

Actualized 30th of November 2012: This game was ported from the Windows 8 metro (WinRT) version, which was written in multiplatform framework MonoGame. For the desktop version I have used the original XNA 4.0. The UI remained almost the same, the only changes were in the saving files (there is no Remote Storage on the desktop), I needed to tune a little some DPI handling and to add a multitouch support (it works even on the Windows 7 now!). I have also added a new Exit button (you can't do a shut down gesture in the desktop app, beside in the Windows 8 metro) and I've changed the message dialogs (run new / continue game).

For the data saving I have used an IsolatedStorageSettings desktop implementation. It worked like a charm.

Multitouch support was a bit harder - there is no support in the XNA 4.0 for the multitouch, it worked in the RTM, but i wasn't included in the final version. So I needed to go deeper :) And I needed to use a Windows 7 Multitouch .NET interop sample library. It worked almost OK, but the touch experience on the ultrabook wasn't good. The XNA's game loop runs aproximately 60 times per second. But the event driven Interop API could be faster, so in the one game frame it was sometimes called a Pressed event, as well as a Moved event (and the game loop seen only the second one). So I needed to do some caching. And I also needed to multiply all the touch positions by selected system DPI

public List<TouchLocation> InteropTouches = new List<TouchLocation>();
private readonly Windows7.Multitouch.TouchHandler touchHandler;

public WindowsTouchHelper(GameWindow window)
        // Initializes handlers
        touchHandler = Factory.CreateHandler<Windows7.Multitouch.TouchHandler>(window.Handle);
        touchHandler.TouchDown += OnTouchDownHandler;
        touchHandler.TouchMove += OnTouchMoveHandler;
        touchHandler.TouchUp += OnTouchUpHandler;

        // Load actual screen DPI
        using (Graphics graphics = Graphics.FromHwnd(window.Handle))
            dpiCoef.X = graphics.DpiX / 96f;
            dpiCoef.Y = graphics.DpiY / 96f;
    catch { }

The last problem was, how to prepare the installer for the Intel AppUp :) It had to include an XNA, as well as the game. And it needed some "silent install" requirement, so the standard ClickOnce solution was not OK. But I have used this instructions list (only changed some values for the XNA 4.0) and it was finally without problems. The submission process was fast and smooth.


Actualized 30th of November 2012: This game is now available for download on the Intel AppUp! Lets give it a try :)

We hope you like this game and want to support us in the next development. Fell free to write us any questions! 

We are also working on PC versions of other our projects - for example the game Glow Arkanoid from Windows Phone, or the app Handwrite Notes.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tomas Slavicek
Software Developer
Germany Germany
Independent C# developer, focusing on mobile platforms, interested in game development. Microsoft MVP in the XNA/DirectX category (2012) and Visual C# (2013). Author of a series of articles about XNA and Windows Phone 7 development. Organizes lectures and hands-on-labs for developers.

Creator of more than 8 games (HexaLines, Glow Arkanoid...), the app Handwrite Notes and the 3D game engine for Windows Phone. Focusing on performance solutions with fast rendering speeds. Now working with MonoGame Framework on several Windows 8, Android and iOS projects (apps and games).

My work on Intel AppUp:
LinkedIn profile:
Interview on a Nokia dev blog:

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Martin Zikmund18-Oct-12 8:58
memberMartin Zikmund18-Oct-12 8:58 
QuestionLooks good. A Desktop version? Pin
Chris Maunder17-Oct-12 7:40
adminChris Maunder17-Oct-12 7:40 
AnswerRe: Looks good. A Desktop version? Pin
Tomas Slavicek17-Oct-12 8:47
memberTomas Slavicek17-Oct-12 8:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161021.1 | Last Updated 30 Nov 2012
Article Copyright 2012 by Tomas Slavicek
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid