Category: This website

A new beginning – C#

A new beginning – C#

Image by Please Don’t sell My Artwork AS IS from Pixabay

You may have noticed, I stopped posting here a while back because basically I ran out of ideas for C related games stuff plus I was doing other stuff that wasn’t relevant (Delphi, C#).

I will get back to finishing my 2nd eBook, but for now, I’m working on a web/mobile game that isn’t really C related. However I thought I’d cover development of it here. as (a) part of it is C# (so technically it’s C and (b) it’s a game.  The backend part is C#, the front end Flutter which is Dart. I’m also going back to my old game design roots as the game architecture is ‘Postal Game’.

What is ‘Postal Game’ architecture?

Well first a little potted history.

Back before the web existed (late 80s), people used to play games by post. They’d fill in a postcard with the orders, post it to the game provider who would enter the details in a computer, process the game then print the results out and post that back. I discovered this (in the UK) back in 1986 and created a postal game: Casus Belli. A 16 player version of Empire. It ran for a year or so and I even attended a postal games conference with a stall back at the start of 1987 in London. By chance, the stall next to mine was run by KJC Games and we got chatting. Kevin J Cropper (The KJC of KJC Games) said “If I ever wanted to sell the game contact me” and at the end of 1987 I did and found myself working for KJC Games as a game designer and programmer in Cleveleys (just North of Blackpool). It was a small cottage industry in the UK and KJC Games was the biggest fish in this admittedly small pond.

Over the next two and a half years I created the 100 player version of Casus called Warlord. Long after I left they ran games across the web and though they don’t run it any more you can still see the page for it. My big creation was a 1,000 player postal game called Quest which KJC still runs. Not bad for a game created in 1989! They still have my name in the Advanced rules which is nice as I last did some work on it in 1996. It took me a year and 40,000 lines of code (Turbo Pascal 5) to create. The others listed helped test it, made suggestions and Steven Fairbrother who came along after I left, fixed my bugs.  When you write 40,000 lines of code in a year, there are a few bugs included…

So each turn gets posted in, processed, printed and posted back. The architecture is the same except its all now sent across the web. There’s a front end programmed in Flutter. This makes it possible to use the same code for Web and mobile development. The game is processed at a fixed rate. In this case I’m going for every three hours but slower or faster is possible. When it’s time, all orders are processed and the results made available to be fetched from the web or mobile device.

Pros and Cons

A Game Processing Engine (GPE) is a completely different kettle of fish from your traditional multi player game server. Hardware requirements are much less and you don’t manage multiple players all at once. Basically the game web/mobile uploads a zip file from each player to send in the orders and then fetches one containing the results. The GPE maintains game state, processes all orders, outputs all results and backs up the game, both before processing each turn (in case it goes wrong so it can be fixed and rerun) and afterwards,

So I’ll be posting here about my progress, programming issues and so on. If you have any queries, please don’t add them as comments – I delete any non-technical comments so instead use the contact form via the About me link on the top.



Widening the scope of this website

Widening the scope of this website

Image by levelord from Pixabay

When I first started, I wanted this to be for two purposes. Learning C programming and learning games programming. Apart from a few more tutorials that I have to complete, it’s mostly complete as far as C goes.  I still have to finish my 2nd e-book which is now up to chapter seven. I received some advice after my first eBook and so I’ve completely revised the second one to have a lot more explanation.

But after a year of doing mostly C stuff (and a bit of C#), I have found it harder to get things to write about on C.  I’ve been revising what I’m doing in games programming and so am looking about. I do like Blazor but am going to try an alternative approach. If I succeed, you’ll hear a lot more about it.

The picture probably represents the contents of my head!


So no response to the programming challenge

So no response to the programming challenge

Pen and paper
Image by Karolina Grabowska from Pixabay

A month ago I set a programming challenge but have had no response.  This could be not enough visitors (about 15-20 a day), or the nature of me posting daily on a WordPress blog where entries vanish.

That challenge was to identify the 100,000th number in a sequence of nine digits numbers that start at 1234567879 and finish at 987654321 where each digit only appears once. It’s relatively easy to program.

It’s also not that difficult to do manually if you think of factorials. As each digit appears once there 9! different numbers possible. There are 9 possibilities for the first digit then 8 for the second and so on. 362,880 in total. (I think…).

So of all the numbers in the range the first 8! (40,320) must start with 1, the 2nd 8! with 2, the 3rd 8! with 3. So the 100,000th is going to start with a 3 as it occurs somewhere between the 80,640th and the 120,960th. You can then apply the same logic to work out where the 2nd digit is going to lie and so on. I did it on a piece of paper and it took me about 20 minutes to figure.

You don’t need maths (or math as US readers will be familiar with) to program computers but on occasions it can come in handy. Especially with games and random numbers, combinations and so on.

Some awesome listings

Some awesome listings

Awesome stamp
Image by Pete Linforth from Pixabay

It has become a thing to label a big collection (usually open source) as awesome and there are several such collections around for many programming languages. In fact the C code collection’s first entry is to one of them.

That said they are pretty awesome, often having links to many related and useful open source projects. My only problem with the likes of GitHub and SourceForge etc. is the sheer quantity of excellent stuff on there. These awesome links are one way to “tame” them.

So now there’s a new link up top for C# and MonoGame links and a couple of entries to start it off.


Another extension to the scope of this blog

Another extension to the scope of this blog

MonoGame application running on AndroidWhen I started this blog at the end of February it was to assist sales of my ebooks. The one written and the one being written. Things have changed a bit and the one being written is now the Raspberry Pi book. That book is still being written but it’s not as high a priority now.

But I also have another side project underway which is to do with mobile game development (and maybe eventually Raspberry Pi).  The only thing is, this project uses C# not C or C++. However it is games related and as its my blog, I’ve decided that I shall write about it here as well as the C stuff. So get used to hearing about MonoGame, XNA and Xamarin.

Just so you know. Xamarin is the company (bought by Microsoft a few years back) that was formed by the founder of the Mono Project (Miguel de Icaza)  and is an excellent cross-platform technology for iOS and Android development based on C#.  I wrote two mobile apps (both sadly derailed by events) one of which was the equivalent of the Uber app. I managed to store every one of the 29 million UK postal addresses in the RAM of an iPhone 6.

XNA was a Microsoft technology for creating games on Xbox, Windows and Windows Phone some ten years ago. It reached version 4 but was then dropped by Microsoft. However the MonoGame project took it over and MonoGame is XNA reincarnated.  It’s cross-platform and runs at 60 fps.

The only technology that I believe can rival Xamarin is Google’s Flutter but it is still too new and doesn’t do games. The C# code runtime adds 3.5 MB to the overall executable but is very efficient and fast.

The image is an Android phone I have running an app. It doesn’t look much but that menu will display with the same height and width on any Android phone.  The problem with Android development (compared to iOS)  that there’s over 20,000 different size screens compared to a dozen or so on iOS. My program is scaled to a fixed virtual size and then tranforms that to the real size. MonoGame lets you do that.

A simple programming challenge

A simple programming challenge

Image by Arek Socha from Pixabay


Around 1981, a British computer magazine (Personal Computer World) had a programming contest and this was one of the puzzles.

There are many 9-digit integers in the range 123456789 to 987654321 where each digit only ever appears once. What is the 100,000th number in this sequence?


The first number is 123456789, the second is 123456798, the third is 123456879 and so on. No digit can repeat so 122345675 is not a valid number in this sequence.

The problem was “Write a program in C or C++ that outputs the 100,000th number as fast as possible. Use any algorithm, except you cannot pre-calculate the answer and then write a program that just prints the result (Somebody actually tried it). Your entry must calculate the number!”.  I’ll give this a month so the deadline is August 14th 2020. Please don’t copy any of the existing answers- you can with a bit of poking around and yesterday’s blog entry find some answers to this.


Er fame and glory and a mention on here!


It’s possible to solve this by hand. I did, back in 1981. It took me 20 minutes with a pen and paper. I also wrote a 6502 assembly language version of it than ran on a Vic-20. It took something like 10 hours to count up to the correct answer.

Slight change of pace

Slight change of pace

Image by Gordon Johnson from Pixabay

I’ve managed one blog entry per day for the last 134 days but a change in side project (I was writing a book to be published, not an Ebook)  but that has to be delayed by at least a year because of an issue at the publisher. In fact I may just publish what I’ve done as my 2nd Ebook.

I’m currently working on networking on a Raspberry Pi. Unfortunately it has to be in C# not C. Networking is a lot easier in C#- you have OOP, task parallel library (far easier than threads), thread pools,. concurrency with async/await and a lot more.  And I can use C# with .NET core or Mono on the Pi.

That said, I will still continue on with game development on the PI. I’ve got my Match Three game half done; I’m quite proud of it and want to get it finished. But I may switch to a slightly less frequent blog posting schedule…


Slight change in direction – more C++ and Pi

Slight change in direction – more C++ and Pi

Raspberry Pi
Image by planet_fox from Pixabay

As I said recently, writing about C and games probably isn’t enough to sustain this site, but if I extend it to include C++ and Raspberry Pi and still maintain the overall direction of writing about game development then that I think will do it.

So I’ve added a new page for C++. I’m currently working on the C++ version of Asteroids and making good progress.

I’m striving to write it in modern C++. To that end, the first entry in the C++ page is a link to a very long document: C++ Core Guidelines written by two luminaries of the C++ world Herb Sutter and Bjarne Stroustrup (creator of C++). You should definitely give it a read.

Interesting fact about the Raspberry PI. Did you know that in March 2020, they sold 640,000! That’s pretty amazing! And while that article says that AAA game playing isn’t something you can do on a Pi, we now know that you can run simple 2D arcade quality games on a Raspberry Pi 4.