As part of the process of learning Nim, I've ported my game _Gravitate_ (a 
variation of TileFall or the SameGame), to Nim.

I used the [NiGui](https://github.com/trustable-code/NiGui) library, so no 
third party `.so`'s or `.dll`'s are needed.

Although I've tried to make the most of Nim and to be as idiomatic as possible, 
I'm sure there's room for improvement. So I hope that some Nim experts will 
review the source and give me feedback -- or just edited `.nim` files -- to 
help me improve my code. (For example, in the `game.nim` file's `start()` 
function it takes me 4 lines to choose 4 unique random colors from a sequence 
of 17; surely it can be done in less code?)

There are two archives available from the game's [home 
page](http://www.qtrac.eu/gravitate.html). The direct downloads (both including 
64-bit executables and full source code <1 KLOC) are 
[Windows](http://www.qtrac.eu/gravitate-1.0.0.zip) and 
[Linux](http://www.qtrac.eu/gravitate-1.0.0.tar.gz).

Things I couldn't do because either I can't figure out how or because NiGui 
doesn't support them:

  * Underline keyboard accelerator letters, e.g., the New game button shows 
"New", but I'd like the 'N' underlined.
  * Include icons in the buttons and to set the executable's icon all in code 
(e.g., by reading base64-encoded text from a file at compile time).
  * Show tool tips.
  * Do gradient fills.
  * Control focus, e.g., stop the buttons getting focus so you can "click" a 
tile with the Spacebar. (The current workaround is to press 'd' for delete 
tile.)
  * Enable/disable buttons, e.g., disable the Options dialog's OK button if any 
option is invalid.



Despite the above, given how small and convenient NiGui is, and how it can be 
used to create stand-alone GUI executables, I think it is a superb library.

And I'm also enjoying learning Nim very much!

Reply via email to