“Old School” — a Little Monkey X Demonstration

Soon the year 2015 will be on the pages of history. I made today a little demonstration in Monkey X with Mojo2.

The demonstration is called “Old School” — for the good old Amiga days. See the video below:

Below is the source code:

Some words about the source…

The bitmap font is made with my Font 2 PNG. On the Font 2 PNG page is explained the file structure of the font.dat file.

The new thing to me was to try the lightning effect with Mojo2. In the code to variable gfxBG is loaded one image, but in order to get the lightning effect working, one needs to make 3 versions of the image. All those three images are used while rendering the effect. The naming of the image files goes like this: name.png, name_n.png and name_s.png.

The letter “n” stands for normal, “s” for specular. These are map files for the lightning. That’s all I know from the documentation of Monkey X Pro.

Feel free to use the code above as you wish.


New version of “Old School” video:


3D Stars with Mojo2

As an example of using Mojo2 module in Monkey X, I wrote the 3D stars using Mojo2 module in Monkey X.

In earlier post the stars were made with the old Mojo. Mojo2 has lots of nice features to experiment with.

Below is the source code in full:

Feel free to use this code.

Perhaps the Most Important Rule In Programming

This is something that I have learned the hard way. 🙂 Don’t code when you are tired, night time really isn’t the best time to code. It may be the case that you’ll have to do everything at least twice.

Also when posting or publishing something, it’s better first sleep over night.


Image courtesy of Peter Haken at FreeDigitalPhotos.net


Scaling Bitmap Font Made With Font 2 PNG in Monkey X

This time a little tutorial on how to scale bitmap font made with Font 2 PNG in Monkey X.

The code uses DrawImageRect command to draw the font. The font.dat file has two 4 byte integers for each character. First is the starting position in the PNG-file in pixels, the second is the width of the character, in pixels. These are consecutively for each character.

The text is centered with the current scale. In order to get the text appear correctly, in drawString function also the width of the character must be multiplied with the scale.

As for the Font 2 PNG, the font is saved with black background color and in the code the blend mode is AdditiveBlend and the font looks smooth.

Here’s the code:

You may use freely this code.

Below is a YouTube video of this tutorial:

Another Game That I Dream to Create

This goes again to the nostalgia category. I really would like to make my own version of Commodore 64’s Stix.

This is a classic game from the year 1983. Below is a screenshot from C64 emulator:


The idea is to fill 75% of the playing area by turning 90 degrees from the direction the player is going. Kind of addictive game!

This idea could be refined to something more interesting…

Nostalgia: Missile Attack

Again, some nostalgia. I remember, that it was late 80s, when I had a game called “Missile Attack” for Amiga. It was shareware game priced at $5.

Many years ago I made just for fun my own implementation of this classic game in Blitz3D. For curiosity, if my memory serves me right, in Terminator II young John Connor is playing this kind of game in one part of the movie.

In this blog post is shortened version of my Missile Attack game. The code is quite messy. I hope there are not any horrible bugs in this old game. This is the first time the game sees the daylight.

Copy paste the code to Blitz3D and start playing, it’s really quite fun, though quite pointless. 🙂 No external files are needed.


Instructions for playing:

  • Use mouse to shoot the missiles
  • Space bar for full destruction
  • When at least 2 missiles are shot with one shot. the player is rewarded by bigger shot
  • If a missile goes to the side of the screen, player’s energy decreases
  • If missile touches the line at the bottom of the window, the game ends
  • If the player clears the screen by firing, the player is rewarded by giving 3 full destruction balls

The code isn’t really commented, sorry!

Touching an object in Monkey X

I’ll share here something that is related to a project I’m working on.

How to test if the user/player has touched an object on the screen. In our example program the object is the following (you may download the object):


My little code tests if object is touched while it moves around the screen. The test is pixel accurate.

The idea is to use a databuffer where the image’s pixel data is stored as integers, which is done by using the LoadImageData command. Each pixel takes 4 bytes of space in the buffer.

The alpha component is set to zero; the remaining bits represent the RGB values. Each integer is stored in variable data. If data <> 0 then the player has touched the object. Only the pixel of the image that has been touched, will be tested.

The code below clarifies this:

This code can’t be compiled to HTML5 target, so you’ll have to try this code in Monkey yourself to see how it works. In free Monkey X this can be compiled to desktop, in Monkey X Pro the code can have also Android target.

Feel free to use this code!

Updated 3/8/2016

Below is a bit more advanced code, where you can use an image where the background color isn’t transparent.

You may download the ball2.png file used in the code (the image has white background color):


The code masks the image with given mask color in function MaskImage, in the example mask color is 255,255,255.

Updated to handle scaled graphics.

Feel free to improve and use the codes above!

Below is a video demonstration of the code above:

How to capture a screenshot from BlitzMax 2D fullscreen game

It’s of course possible to capture a screenshot from BlitzMax fullscreen game with video capture programs such Fraps. It can be also done with the in the BlitzMax code of the game. Here’s my little code to do it:

One must define a Pixmap to which the screen’s content is grabbed. When the contents are grabbed the pixmap is saved as JPEG picture by name “filename.jpg”.

In this example program the screenshot is taken when key c is pressed and saved as jpeg-file.

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: http://www.freesfx.co.uk, when using their library.

One of the probably finest sites for free music and sound effects is Soundimage.org. 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 Shockwave-Sound.com. 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