I Haven’t Followed the Time

I’m living in the past too much, such speaking. This reminds me what Yoda said to Luke Skywalker in episode V: ”Always he has looked into the horizon, never where he was, what he was doing!”. Or something like that.

I started 2015 an Android game project, I haven’t touched for a long time. Much have changed since I started that project. The pro version of Monkey X saw many updated versions with mojo2-module while I was using old mojo-module in my project.

Later I updated the code for mojo2, but how fast the time flies: Monkey X has gone completely open source and I don’t even know when that happened… Today I installed latest open source version of Monkey X from Blitz Research.

But since I seem to live in the past, I’m going to find time to finish my Android game with old Monkey X (with mojo2).

What’s well.. ”special” in this game is, that all the musics will be composed by me. Though, I haven’t been making so called tracker music ”seriously” (if ever) for a long time… Though, for testing this game project I will be working again, I already have made four short tracker music compositions last year – and one short piece of music made with PC’s ProTrekkr.

Though, to pity for the potential players of this game, I probably must compose new tunes… 🙂

When finished, the game will be free.

Bouncing of the ball when it touches the Bat (80s Krakout style)

It’s night when I’m writing this. I came up with a little Monkey X tutorial on how to program the bouncing of the ball, when it touches the bat in the “old school way” — like in the popular C64 game Krakout in the 80s.

In the video for the tutorial you can see, that as the ball touches the bat for the first time, delta y doesn’t change. This is because both the ball and the bat are uneven as height in pixels; now both the ball and the bat have a middle point.

This is just a short piece of code, that doesn’t handle the case, when the ball is at the horizontal top or bottom of the bat. There’s some extra work for anyone who wants to make an 80s style Krakout game. 🙂

The delta y for the ball is calculated simply how the ball’s y-position is related to the middle point to the bat. The “scale” variable is used to adjust the max y-speed of the ball. If you are new to Monkey X, remember that with Pro version, you can compile the code to the Android target among many other targets. See the Store page.

Source code below:

Feel free to use and improve the source above in your own projects.

Here’s the graphics to download (license: public domain), except the background picture:



The bat is 32 x 73 pixels as size, the ball is 16 x 17 pixels.


For comparing to the C64’s popular Krakout, see the video below:

Many years ago I started to program Krakout style game in the spirit of the good old Commodore 64, but as usual, something went wrong. Three months work with multiple levels and a level editor programmed in Blitz3D were lost because I hadn’t taken backups of the files, when I, well, “fixed” the Windows installation I had at the time…

Scrolling a Picture Larger Than Visible Area in Monkey X

A little tutorial on scrolling a picture that is larger than the visible area of the screen in Monkey X.

In this example we will be using a picture of 1280 x 960 pixels in “native” resolution of 640 x 480 pixels. The source is primarily meant to Android target but works for example to desktop target too.

The picture is scrolled by moving a finger on the Android device. In order to avoid the picture to “jump” after not scrolling the picture, variables related to scrolling speed must be set to zero.

Lets have a look at the source code:

Examine the source code and learn. Source code license: Public Domain.

Below is a video related to this post:


Missile Attack in Monkey X

Again, some nostalgia. In older blog post I presented a shortened version of my old implementation of Amiga’s “Missile Attack”. This night I made the game in Monkey X and the source can be directly compiled to Android target.

The game is quite simple one: Just shoot the missiles before they get to the bottom of the screen.

If a missile goes to the left or right side of the screen, you see the colors of the background changing — and also when you fire a shot. This gives the game more life. 🙂

Below is the source code:

Source code license: GNU General Public License 3.0.

Below is the video of the game on Android tablet and on computer screen:

I may make a better version of the game later on this summer…

How to Make a Worm Game Part 2

(Updated 03/05/2017 with improved source code and new video)

A little update to older post. As the title of the post says we’re making a worm game (in Monkey X). In this version the worm is controlled by touching the screen keeping in mind that the game is really aimed to Android.

I’ll explain here how the worm is controlled.

If you move your finger ”up” from the worm’s head, the worm goes to that direction and respectively to other directions.

See the video below:

The direction is determined by comparing two subsequent update rounds’ TouchX() and TouchY() coordinates.

The test can’t be straightforward TouchX() or TouchY() test, because the player probably won’t move his/her finger absolutely to one of the four directions the worm is to be controlled.

This is why there is another test in controlling the worm: The absolute values of difference of the two subsequent update round’s TouchX() and TouchY() coordinates. If the player wants to control the worm ”up”, the player probably has moved his/her finger more vertically than horizontally.

See the source code:

Source code license: Public domain.

Notice, that in this code one part of the worm’s “body” is 17 x 17 pixels, but the worm moves with step of one pixel and can be controlled with accuracy of one pixel. The example code above is simple implementation of this kind of worm game. The down side of the code is, that the sizes of the arrays for x– and y-coordinates depend of the length of the worm in pixels.

I may come back later with some implementation with different concept of moving the worm of which “body” is built with “blocks” of different size than one pixel, but the worm is controlled  with accuracy of one pixel, without using arrays of which lengths depend on the size of the worm in pixels.

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:

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.