How to make a worm game

Let’s have some nostalgia here, we’ll take a look, how to make a simple worm game. The example codes have been coded in Monkey X Pro, but can be compiled with free Monkey X to desktop and HTML5. Perhaps someone will develop a fun worm game with Monkey X Pro to Android. 🙂


First, simple code where the player can just control the worm, that moves the very old traditional way:

Then a bit more advanced code, where the worm moves with step of one pixel, but one part of the worm is an oval that’s width and height are 16 pixels. This version is also a little game where eating the food lengthens the worm.

If you wan’t to see how above code works in practice, click here to play (HTML5 game). Feel free to use these codes.

Where to get sound effects and music

Updated 18.6.2018

In my early times I’ve used FreeSFX for example in Ball Shooter. The sound effects and musics from FreeSFX can also be used in commercial software products. In the credits for the sound effects and musics FreeSFX must be mentioned as follows:, when using their library.

One of the probably finest sites for free music and sound effects is There are simply amazing compositions for free, you only need to put attribution information to your product.

There are also many sites, that sell royalty free music and sound effects. Personally I like very much the music collection of There is also fine collection of sound effects at Shockwave-Sound. The customer service of Shockwave-Sound is also excellent. Remember to choose the right kind of a license when buying.

Also great site for music to YouTube videos!

Link: Shockwave-Sound

HTML5 3D Stars

The 3D stars are again embedded in this blog post and source code with old mojo is simplified.

The code is written in Monkey X Pro, which is nowadays available on

Here’s the code:

Do use my code as you wish.

A Game That I’ve Always Wanted to Create…

The computer games that have given me best gaming experiences ever, are Commodore 64’s Ultima IV and Ultima V. In my youth I always wanted to create a game like these. Many, many years ago I even started making some kind of Ultima like game on Amiga in assembly and C, but I never got that project finished. I made everything myself, the code, graphics and musics.

Here’s a screenshot from work in progress from WinUAE (Amiga emulator):


The screenshot is from a demo written in assembly where there is jumping scrolltext (in Finnish) with the three bitplanes jumping separately. In the demo there’s a little world where the boy in the picture wanders, destroys ghosts and in the end finds his love…

Both demo and the unfinished game that is written in C use Amiga’s system routines. The unfinished game doesn’t have (of course) a scrolltext. The graphics that are made with Amiga’s Deluxe Paint II, are only experimental…

Hopefully I will sometime in the future find time to make this kind of a game for PC, probably in BlitzMax. Because of lack of time, I prefer nowadays to use a programming language, that makes it possible to get something done pretty quickly. And for the sake of nostalgia, the game would have 2D graphics like the original Ultima IV and Ultima V of Commodre 64 (and Amiga).

In the scrolltext it says: ”[Ja he] elivät onnellisina jne…” That’s in English: ”[And they] lived happily etc…”

Hex 2 Dec

In many programming languages there is built-in command or function to convert a decimal value to a hex value. But at least in BlitzMax there isn’t a command or function to convert a hex value to a dec value. In this post I present my little function to convert a hex value to dec value in BlitzMax and in C.

The BlitzMax function:

First, put somewhere in the beginning of your program line

The function itself:

The C version is a complete program that uses its functions:

Be careful with the C version: It doesn’t check if the input is correct. As you can see from the code the letters in the hex number should be given in capital letters. Feel free to use and improve these codes!

How to make an installer

How to make an installer with NSIS

Code updated to work on Windows 10 properly.


Many people may have a finished product but lacking an installer for the product. There are lots of installer creating software, but some of them are very expensive. NSIS is a free installer scripting system from Nullsoft. I use it in my products. In this blog I present my example script that gets beginners started.

At first NSIS may seem complicated, but fortunately it has many macros, that make creating an installer an easy task. The picture below shows one page of the built example script presented at the end of this blog post.


Now, let’s get on with NSIS.

An NSIS installer has one ore more pages. The pages are created with macros in the script (in our example).

Furthermore, every script is build up with sections. Each section except the uninstaller section is shown in the ”Choose Components” page as shown in the picture above.

In our example script we are using the modern user interface, MUI in short. First there’s defined some constants, that make life easier later in the script and make the script easily re-usable. The example script installs for all users. The line

SetShellVarContext all

means all the users. And in the registry key registration HKLM is related to all users.

Enough, let’s see the commented example script (name it as myscript.nsi or something):

Other environment variables that often are needed, when creating an installer are $APPDATA and $DOCUMENTS for the %AppData% folder and Documents folder respectively.


Skeleton for an Android app

Android as a platform is very hot nowadays. Many people want to develop software for it and the base of end users is growing all the time. Probably because Android based devices are everywhere, they exist in form of smart phones, tablets and TVs.

One basic rule for an Android app is that it’s graphics shouldn’t be fixed sized, the graphics should be scaled into target Android devices resolution. In this short blog I present my skeleton Android program that scales it’s graphics into target android devices maximum resolution and as a convenience has an exit button. Application’s own exit button is one feature that I miss in many Android applications.

The code is written in Monkey X Pro, which is a great multiplatform programming language from Blitz Research Ltd.

To the code…

The program draws fullscreen yellow background, an exit button and a ball that moves around the screen.


Compiled to desktop

The scaling is made by pushing current drawing matrix to internal matrix stack and then scaling it by the screen ratio.

With free Monkey X you can compile to desktop and HTML5 and it comes with MinGW that is also needed in Monkey X Pro.

How to retrieve the %AppData% folder

AppData folder is used to store data like hiscores, config, etc. of a game (or app). The AppData folder is a special folder that’s location is related to Windows version one is using. This is why AppData folder must be retrieved with the aid of the system.

In Blitz3D retrieving the AppData folder is as simple as this:

AppDataFolder$ = GetEnv$(”AppData”)

In BlitzMax retrieving the AppData folder isn’t this straight forward. The easiest way to get the location of this special folder is to use external module, BAH.Volumes. Once this module is installed for BlitzMax and imported in the beginning of the code, retrieving the AppData folder is as easy as this:

AppDataFolder = GetUserAppDir()

Above is assumed that the variable AppDataFolder is defined as String.

In order to install external modules to BlitzMax, MinGW must be installed and configured for BlitzMax. The BlitzMax product page has a link to forum topic that explains how to set up MinGW for BlitzMax.

Link: BAH.Volumes (from Google Code)


With good old ANSI C the %AppData% folder can be retrieved as follows: