zsmb's prog site

Bits

  2015.07.22.

Introduction

This one is a very simple and very quick project, basically written and published in a day. It's a simple clone of the game you can find on the Google Play Store under the name  Grid of Bits, which I thought was pretty cool for the simple game it is. The original (written in Java) can be also found on GitHub  here, although I did not look at the source code.

Description

Making this one was pretty straightforward, the main idea behind it is that there's are two grids stored for each game, one hidden and filled randomly with ones and zeroes, the other being the one that the player can manipulate.

I know that some of the code isn't exactly optimized, but looping through NxN squares had good enough performance that it was worth doing to make the code easier to read (I hope it is, at least).

Other than the lack of cool animations (you really should check out the original app, it's way cooler) and the lack of How to Play menu it's pretty much the same as the real thing. Three difficulties, top three scores for all of them stored. Nothing revolutionary, but it was a good game to make for practice.

The one thing I added was a configuration file which you can edit to change the colours used in the game, with the exception of the text colours because those are in RGB form, while the others are just single hexadecimal numbers. If the colours.ini file doesn't exist, the game will use the original colours, and it will not create one on its own. A scores.dat file will be created if necessary.

I (more or less) took the code for rendering TTF fonts in SDL from my  Hangman project, with only slight changes going from SDL1.2 to SDL2. Please note that the executable depends on SourceSansPro-Regular.ttf being in its directory, as it is used to render text in the game.

Downloads

Downloading the zip file that contains the executable results in a warning (at least in Chrome) as a security measure, but you can choose to "Keep" it.

Name Description Size Date
bits.cpp Source code 18 KB 2015.07.22.
colours.ini Optional config file 1 KB 2015.07.22.
bits.zip Windows executable with dll's 1497 KB 2015.07.22.
bits.tar.gz Linux project with Makefile and SDL_gfx 360 KB 2015.07.22.