As I mentioned in my Surviving Lockdown post, I started upskilling on Python, and when upskilling on a new programming language, I usually do a project to build on and enforce the things I am learning.

For my Python-based project, I decided to use PyGame to develop a small game. One piece of advice I can offer when developing a game is that it is better to develop a small and basic game that you finish than a large and ambitious game you never complete. I believe everyone who has tried some form of game development has at least one over-ambitious project they never completed, so it is better to start small.

The game I developed is called “Space Octopus Invasion” and here is a video of the game in action:

The tools and resources I used in the development process are as follows:

  • Trello
    I used Trello for task tracking and planning.
  • PyCharm
    PyCharm is my favorite Python IDE developed by JetBrains, and it offers a free community edition.
  • PyInstaller 
    A great utility to package a python application into an executable file.
  • InstallForge 
    A free installer maker that allows you to create a professional-looking setup wizard to install your game.
  • GameDevMarket.net
    I am not an artistically inclined person, and typically I use art, sound, and music assets when developing a game, I recommend GameDevMarket.net as they have a great selection of assets available.

The Installer for the game can be downloaded here: Installer.

And the source code can be downloaded here: Source Code.


The Dark Art of DevOps (and how Azure DevOps fits in)

Here is a Post n wrote for my Companies blog, originally posted here.

DevOps has become a hot topic in organisations over the past year or so. However, there seems to be a lot of confusion regarding what DevOps actually entails. So, what is DevOps?

If you asked a more sales-inclined individual, you may get a response along the lines of: DevOps digitally transforms an organisation’s development department by bridging the gap between development and operations, resulting in higher quality solutions, fewer bugs, quicker delivery times, shorter recovery times, and controlling scope creep.”

This sounds amazing! However, it does not answer the question as to what DevOps really is. So, I will be taking a different approach to delve into what DevOps entails.

DevOps is based on the principal of continuous improvements in the Software Development Lifecycle, and consists of principles, practices and tools that allow an organisation’s development department to deliver projects at a high velocity, while maintaining quality and continuously improving the process associated with delivery. This is where Azure DevOps comes in. Azure DevOps is a selection of tools that facilitate the implementation of DevOps within an organisation.

DevOps consists of five main pillars (which are supported by processes, practices and tools), namely:

1. Plan and Track

This involves planning what development work needs to be completed and tracking progress against that. The tool Azure DevOps offers here is Azure Boards.

2. Develop

This is where your software developers write code and store that code. In the Azure DevOps ecosystem, the tools that used here are Visual Studio, Visual Studio Code and Azure Repos as a source code repository.

3. Build and Test

Automated builds and testing are a very important part of DevOps, as this automation frees up valuable resource time to focus on more imperative tasks. Automated builds can be set up to trigger new builds (compiling source code into executable programs) based on certain criteria (for example, “once a day”), and automated tests can then be run to verify that everything is working as expected without the intervention of a person.  Azure Pipelines and Azure Test Plans are the tools utilized here.

4. Deploy

The next step is Automated Deploy – first to a UAT\Test environment and eventually to production. Doing deploys in this manner prevents unwanted changes being accidentally deployed from a developer’s machine and introduces additional controls to only deploy what is wanted and limiting the introduction of problems.  By automating the deployment of systems deployment times are also drastically reduced and thus system down time is reduced. Azure Release Management is the Azure DevOps tool used to automate deployments.

5. Monitor and Operate

After a system has been deployed, it needs to be monitored and operational activities need to be performed to ensure it is up and running and running optimally. Azure Monitor and Application Insights are the tools available in the Azure DevOps tool-belt for this.

With the tools provided by Microsoft Azure DevOps, as well as industry tried and tested principles, the above five pillars can dramatically improve the operations and output of a development department while driving down operational costs.

Now that we understand what DevOps is and how it works, what outcomes can we expect from mastering the 5 pillars?

  • Better quality solutions
  • Quicker delivery times
  • Fewer bugs
  • Shorter recovery times to resolve bugs
  • Prevents uncontrolled scope creep
  • Improved collaboration and agility in teams
  • Better cross-skilling in teams
  • More automation
The Dark Art of DevOps (and how Azure DevOps fits in)


LINQ or Language Integrated Query is part of the Microsoft .NET Framework and it adds native data querying capabilities to .NET languages.

LINQ allows the user to query:

  • Objects in Memory (i.e. collections such as lists) using LINQ to Objects
  • Databases using LINQ to Entities
  • XML using LINQ to XML
  • ADO.Net Datasets using LINQ to Datasets

LINQ can either be implemented using predefined extension methods or alternatively using LINQ Query Operators.

Below are three examples utilising LINQ Extension methods:

In this example a list of Book objects is filtered to return only the Objects where the price is less than 10.

List<Book> cheapBooks = books.Where(b=>b.Price < 10);


In this example a list of Book objects is filtered to return only the Objects where the price is less than 10 and additionally the newly created list of Book objects is sorted alphabetically based on the Title field.

List<Book> cheapBooks = books.Where(b=>b.Price < 10).OrderBy(b.Title);


In this example the cheapBooks list is filtered to only return the Titles of the books therein and these Titles are then inserted into a new list of strings.

List<string> cheapBooksTitles = cheapBooks.Select(b=>b.Title);


Multiple extension methods can be combined to ascertain the desired results, for example:

List<string> cheapBooksTitles = books.Where(b=>b.Price).OrderBy(b.Title);


LINQ query operators tend to be slightly more verbose, and the above example can be implemented with query operators as follows:

List<string> cheapBooksTitles = from b in books
                         where b.Price < 10
                         orderby b.Title
                         select b.Title;


Some common extension methods are:


var book = books.Single(b=>b.Title == ”Building Robots”);

Returns a single object that matches the defined criteria. However note that in the event that none or more than one book matches the criteria specified an exception will be thrown.



var book = books.SingleOrDefault(b=>b.Title == ”Building Robots”);

Returns a single object that matches the defined criteria, if more than one book matches the criteria specified an exception will be thrown, however if no books match the criteria the default value defined will be returned.



Returns the first object that matches the criteria, however if no matches are found an exception is thrown.



Returns the first object that matches the criteria and if no match is found the default value will be returned.



Returns the last object that matches the criteria, however if no matches are found an exception is thrown.



Returns the last object that matches the criteria and if no match is found the default value will be returned.



var maxValue = books.Max(b=>b.Price);

Max is used with numeric values and will return the highest value that is contained in the Price field in the Book objects.



var minValue = books.Min(b=>b.Price);

Min is another operation used with numeric values and will return the smallest value that is contained in the Price field in the Book objects.



var totalPrice = books.Sum(b=>b.Price);

Sum is used to add up all the values in a numeric field.


There are many other methods available to filter and manipulate data in LINQ and the possibilities for the utilisation of LINQ are nearly endless, for example

var bookSelection = books.Skip(2).Take(3);

The above example will skip the first two books in the books list and take the next three placing them into the newly created bookSelection list.

The best option to gain a better insight of what is possible with LINQ is to give it a try.



A lambda expression is a function definition with no name, no access modifier and no return statement. Lambda expressions are also known as Anonymous methods or functions.

The syntax for the definition of a lambda expressions is as follows:

(arguments) => expression

The below C# code does not use lambda expressions and is given as a comparative reference point:

static int SquareNumber(int number)
   return number*number;

static void Main(string[] args)
   Int y = SquareNumber(10);
   Console.WriteLine(y); // This will display 100

The above code can be refactored using a lambda expression as follows:

static void Main(string[] args)

   Func<int,int> square = number=>number*number;
   Console.WriteLine(square(10)); // This will display 100


The result of this refactor is fewer lines of code in order to achieve the same result.

Lambda expressions can also make use of Delegates as shows here:

delegate int squareDelegate (int number);

static void Main(string[] args)
   squareDelegate square = number=>number*number;
   Console.WriteLine(square(10)); // This will display 100


The syntax for a lambda expression that takes no arguments is as follows:


For one argument:


For more than one argument:



Lambda expressions can also be very effectively used with objects that implement the IEnumerable and IQueryable interfaces to filter or search based on defined criteria, for example:

var highPriceList = PriceList.FindAll(a=>a.Price>10);

This will return all items with a price larger than 10, and place these items in the highPriceList.


var nyCustomers = Customers.Where(a=>a.City==”New York”);

This will place all customers with the city property set to “New York” into the nyCustomers collections.

Lambda expressions are an extremely useful tool with many other uses.


Bite Size C# – Eventing\Observer Pattern

Let us have a look at the eventing or observer pattern. This pattern is based on the raising and handling of events. Events are a mechanism for the communication between object that allow us to build loosely coupled applications that can be easily extended.

At a high level this pattern functions as follows:
An object (known as the Publisher) defines a contract (delegate method) to which other objects (knows as Subscribers) must comply in order to be notified of a certain condition occurring in the Publisher object. This is achieved as follows, when a certain state is reached in the Publisher object an event will be raised, which will then trigger all the Subscriber objects to react by executing the method defined within the individual Subscriber objects that matches the delegate method as defined in the Publisher.

Now let us have a look at an example:

First let us create the Publisher, here we have to do three things:
1. Define a delegate which will act as the contract between the Publisher and Subscribers.
2. Define an event based on the delegate.
3. Raise the defined event.

public class KillerRobotPublisher
	public delegate void KillerRobotEventHandler(object source, EventArgs args);

	public event KillerRobotEventHandler KillerRobotAction;

	protected virtual void OnKillerRobotAction()
		if(KillerRobotAction!=null) //check if there are any subscribers

	public void DoKillerRobotAction(string action)
		Console.WriteLine(“Killer Robot is doing “ +action);
		//add additional action logic here


Next let us create a Subscriber to subscribe to the KillerRobotAction event on the Publisher.

public class KillerRobotSubscriber
	public void OnKillerRobotAction(object source, EventArgs args)
     //this method conforms to the delegate defined in the Publisher
		Console.WriteLine(“The Killer Robot did something!”);

Now lastly let us create a basic application to instantiate the objects and to subscribe the Subscriber to the Publisher:

class Program
	static void Main(string[] args)
		var killerRobotPub = new KillerRobotPublisher(); //Instantiate Publisher Object
		var killerRobotSub = new KillerRobotSubscriber(); //Instantiate Subscriber Object 

		killerRobotPub.KillerRobotAction += killerRobotSub.OnKillerRobotAction;
		//Subscribe the KillerRobotSubscriber to the KillerRobotAction event on the KillerRobotPublisher.

		killerRobotPub.DoKillerRobotAction(“A Dance”);

The console output of this application will look like this:


Bite Size C# – Eventing\Observer Pattern

Bite Size C# – Extension Methods

Extension methods allow us to add methods to existing classes without changing the class’ source code, nor by inheriting from the class. Extension methods are more relevant when wanting to add a method to a class from which one cannot inherit, such as sealed classes.
Just note, you cannot use extension methods with a static class as extension methods require an instance variable for an object in order to be utilised.
Let us look at an example, here we will add an extension method to the string class, which is a sealed class (i.e. you cannot inherit from this class).

class Program
	static void Main(string[] args)
		string sentence=  “This is something a person would say.”;

		var robotSentence = sentence.ToRobot();

public static class StringExtensions
	public static string ToRobot(this string str)
		if(String.IsNullOrEmpty(str)) return str;
		var words = str.Split(‘ ‘);
		var robotStr = String.Empty;

		foreach(var word in words)
			if(word.Length > 4)
				robotStr+=“BEEP “;
			} else {
				robotStr+=“BOOP ”;

		return robotStr.Trim();

Also note that extension methods must be non-generic static methods defined in a static class.

Bite Size C# – Extension Methods

Bite Size C# – Delegates

A delegate is a form of a type-safe function pointer. More simply put, it is an object that knows how to call a method, i.e. a reference to a method. Delegates are useful as they assist us in writing flexible and extendable applications.

Delegates are useful when using the eventing design pattern also known as the observer pattern. The eventing or observer pattern consists of an object, called the subject or publisher, which maintains a list of dependent objects, called observers or subscribers, and notifies them automatically of a state change in the subject-object by raising an event and then calling a method on the observer objects by using a delegate. We will cover this pattern in more detail when I cover events in a separate post.

For now, let us simply focus on delegates.

So, let us look at an example:

public class KillerRobot
	public string Name { get; set; }

public class KillerRobotActuator
	public delegate void KillerRobotActionHandler(KillerRobot robot); 	//Declare delegate which will act as a
															//signature for methods that can be

	public void DoAction(string robotName, KillerRobotActionHandler actionHandler)
		var robot = new KillerRobot {Name = robotName	};

public class RobotActions
	public void RobotTalk(KillerRobot robot)
		Console.WriteLine(“{0} is Talking.”, robot.Name);

	public void RobotDance(KillerRobot robot)
		Console.WriteLine(“{0} is Dancing.”, robot.Name);

class Program
	static void Main(string[] args)
		var robotActuator = new KillerRobotActuator();
		var robotActions = new RobotActions();
		KillerRobotActuator.KillerRobotActionHandler actionHandler = robotActions.RobotTalk;
		actionHandler += robotActions.RobotDance;
		actionHandler += RobotPowerOff;

		robotActuator.DoAction(“The Geek”,actionHandler);

	static void RobotPowerOff(KillerRobot robot)
		Console.WriteLine(“{0} has turned off.”, robot.Name);

So, in this basic example we have a class KillerRobotActuator which declares a delegate:

public delegate void KillerRobotActionHandler(KillerRobot robot);

Any method that complies to this signature can then be added to this delegate and in the DoAction method where the following is executed:


All the methods that have been added to the actionHandler will then be executed.
We can see in the Main method of the Program class that a new KillerRobotActionHandler is declared and three method references are added to it as below:

KillerRobotActuator.KillerRobotActionHandler actionHandler = robotActions.RobotTalk;
actionHandler += robotActions.RobotDance;
actionHandler += RobotPowerOff;

And then finally the DoAction method on KillerRobotActuator is executed, passing in the above declared actionHandler containing references to the three methods:

robotActuator.DoAction(“The Geek”,actionHandler);

All three the methods that are referenced by the actionHandler comply to the signature defined in the delegate declaration in the KillerRobotActuator class. i.e. a void return type and an input parameter of type KillerRobot.
It is also worth mentioning that of the methods referenced, two are contained in a separate class RobotActions and the third is a static method declared in the Program class, so methods from multiple different class locations can be added as long as they comply to the signature of the delegate declares.


Bite Size C# – Delegates

Bite Size C# – Generics

Generics refer to the method of creating classes and methods in a way that defers the specification of the type or types associated with the class or method until it is declared and instantiated.

What this means in plain english is that you can define a single class or method that can be utilised with multiple types, thus resulting in less and tidier code.

So let us have a look at an example. Firstly let us look at some code that is not generic. Here we have a class which consist of a list of integers, it has a default constructor as well as two methods, one to add an integer to the list and the other to return the sum of all the integers in the list.

public class KillerRoboticsIntList
   public List<int> IntList { get; set; }

    public KillerRoboticsIntList()
        IntList = new List<int>();

    public void Add(int item)

    public int Sum()
	int sum;
	foreach(int i in IntList)
	 sum += i;
	return sum;


This is a very basic example and can be utilised as follows:

class Program
            public static void Main()
                KillerRoboticsIntList iList = new KillerRoboticsIntList();
		        int sum = iList.Sum();
                Console.WriteLine(“Sum = {0}.", sum);


This is very straight forward, however if I would like to use this class with a data type other than int (for example a float or a double) I would need to define a new class for each data type. This can be overcome by utilising Generics. Below is an example of how this can be implemented:

public class KillerRoboticsGenericList<T>
   public List GenList<T> { get; set; }

    public KillerRoboticsGenericList()
        GenList = new List<T>();

    public void Add(T item)

    public T Sum()
	T sum;
	foreach(T i in GenList)
	 sum += i;
	return sum;


The above class can now be defined for various types as seen below:

class Program
            public static void Main()
              KillerRoboticsIntList<int> intList = new KillerRoboticsIntList<int>();
		        int sum = intList.Sum();
                Console.WriteLine(“Int Sum = {0}.", sum);

		        KillerRoboticsIntList<double> = new KillerRoboticsIntList<double>();
		        double dSum = doubleList.Sum();
                Console.WriteLine(“Double Sum = {0}.", dSum);


In some cases you might want to put a restriction on the types that can be utilised to implement a generic class of method, this can be achieved by utilising constraints. For example the class we defined above can be restricted to types that implement the IComparable interface by simple changing the first line as follows:

public class KillerRoboticsGenericList<T> where T : IComparable

Some additional examples of constraints are:

where T : Product

This restricts the type of T to an implementation of the class Product or any of its child classes.

where T : struct

This restricts the type of T to the value type struct.

where T : new()

This restricts the type of T to an object with a default constructor.

Multiple Constraints can also be appled at the same time, for example:

public class KillerRoboticsGenericList<T> where T : IComparable, new() 

A Generic class can be defined to utilise multiple types, for example:

public class KillerRoboticsGenericList<T,U,V>  

It is also worth mentioning that the default c# List class used in the above examples also utilises generics, along with all the other predefined c# collections contained in System.Collections.Generic.

I hope this post has been useful and I will be posting on some additional C# topics, such as Delegates, Lamda Expressions, LINQ, Extension Methods, etc. over the next few months.

Bite Size C# – Generics

A Story About A Game

15 Years ago I wrote a small game called Hellspawn and I rediscovered it again when I was going through some old backup discs. It is a top down shooter and was developed in Borland C++ Builder (I think version 6). It was a very basic game (especially looking back now) from when I was still a very inexperienced developer, still studying to get a degree.

So if anyone is interested here it is: HellSpawn

To get it working on windows 10:

Use Hellspawn.exe to start the game, but first in file properties:

  • Set executable to run in compatibility mode  – Windows 98 / Windows ME
  • Reduced Color mode – 16-bit
  • Override DPI Scaling Behavior, Scaling performed by – Application
  • Can also set to run in 640 x 480, however is best to change screen resolution in windows to 1024 x 768 for best experience.


The controls are as follows:

  • Arrow keys to move
  • Left ctrl keys to fire weapon

Simply kill all the enemies to proceed to the next level.

On another note I have some Steam game keys to give away!

For a chance to win one simply email killerrobotics.me@gmail.com with the subject line ‘Killer Robotics Steam Giveaway’ and for the message content just be creative.

Winners will be randomly selected and announced via twitter.

A Story About A Game

DIY VR Headset for $80 (DIY VR Part 2)


The purpose of this series of posts was to look at ways to experience VR at home for the lowest cost possible. In Part 1 of DIY VR, we took a look at using a smart phone and a Google cardboard compatible headset to stream computer games to the phone in stereoscopic 3D. The main problem with this approach was that it was still relatively expensive as it required a smart phone (iOS or Android) to function.

Now in part 2 we will look at building a VR headset from scratch. My initial goal was to do this for under $150(USD), however after shopping around and changing some parts out for alternatives I managed to get this down to around $80. So let us get started.

The parts required are:

  • Toggle Flick Switch
  • 2x LED
  • 1x resistor 150 Ohm
  • 1x Micro USB cable (at least 2 meters long)
  • 1x HDMI Cable (thin ones work best as they hinder movement less, also at least 2 meters long)
  • Some jumper wires
  • DC Adapter plug 5V 3A (Raspberry Pi compatible one works great)
  • Push Button
  • Google Cardboard Compatible VR Headset (I recommend one with a phone compartment door that opens as it gives better access than the ones which uses a tray that slides in)
  • 6DOF MPU 6050 3Axis gyroscope and accelerometer
  • Arduino Micro (can use off brand alternative)
  • 5inch RaspberryPi LCD Screen 800×480 with HDMI interface

All of these parts can be acquired on AliExpress for about $80 ($82.78 to be precise), as shown in the image below:

Resistorflick_switchwireDC AdapmicroUSBHeadsetpushbuttonledMPU6050lcdHDMIarduinoMicrototals

You will also require Tridef3D or similar software (there are some free alternatives, but I have not had a chance to give them a try at present). Tridef3D is used to convert any Direct X 9/10/11 game into stereoscopic 3D. Tridef3D offers a 14-day free trial, which is plenty to give this a try. The full version of Tridef3D retails for $39.99.

Now that we have all the required components, let us begin with the assembly.

The assembly comprises of 3 main elements:

  1. The Arduino Micro circuit (containing the MPU 6050, push button and led)
  2. The Wiring (providing connectivity to Arduino Micro and power to Screen)
  3. Inserting the screen in the headset and connecting the micro USB cables as well as the HDMI cable.

The Arduino Micro circuit

The diagram below illustrates how the different components need to be connected to the Arduino Micro:


The push button uses digital pin 5 and the MPU 6050 is connected to the Arduino Micro as follows:

– MPU 6050 SCL pin to Digital Pin 3 on Arduino

– MPU 6050 SDA pin to Digital Pin 2 on Arduino

– MPU 6050 VCC to 5V pin on Arduino

– MPU 6050 GND to GND pin on Arduino

The code to be loaded on the Arduino is as follows:

#include <Mouse.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy;
int inputPin = 5;
bool enableMouse;

void setup() {
enableMouse = true;
pinMode(inputPin, INPUT);
if (!mpu.testConnection()) {
while (1);

void loop() {
int val = digitalRead(inputPin);
if (val == HIGH) { // check if the input is HIGH
//Place logic here to execute when button is pressed
//Disables mouse movement while button is pressed, this allows you to set your view angle easily.
enableMouse = false;
enableMouse = true;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
vx = -(gy)/150;
vy = (gz+100)/150;
Mouse.move(vx, vy);

Just note that the orientation of the MPU 6050 makes a difference to which of the axis of the gyroscope will be used. For the above code the MPU 6050 was mounted on the side of the headset as shown in the pictures below:


In the event of the MPU 6050 being mounted with a different orientation you might have to substitute between the gx, gy and gz values until the desired configuration is achieved.

For my configuration I am rotating around the Y and Z axis.

Also the numbers associated with calculation of vx and vy might have to be tweaked to get the results (movement speed etc.) you desire.

I also added a push button, that when pressed temporarily disables the gyroscopic mouse movement. This is useful when you want to reset you point of view in games.

I attached all the parts of this circuit to the VR Headset using double-sided tape.

The Wiring

In order to have as few cables as possible connecting to the VR headset I modified the USB cable so that it pulls external power from a DC power adapter (a single USB port will not be able to power both the Arduino and the 5 inch LCD) as well as splitting into 2 micro USBs on one end (one only provided power to the LCD and the other one both power and connectivity to Arduino.) the below diagram shows how the wiring is connected:


For reference a USB cables contains 4 wires:

  • Red wire – +5V DC
  • White or Yellow – Data connectivity
  • Green – Data Connectivity
  • Black – GND

I also included a switch to turn the power on and off (this is useful to turn off the mouse functionality until it is needed, otherwise it will interfere with mouse movement when it is not desired) as well as an LED to show when the headset is powered on.


Inserting Screen in Headset and connecting all the wiring

The LCD screen is held in place by the clamps in the headset used to hold a phone (it is a snug fit). Then simply connect the 2 micro USBs to the LCD and Arduino respectively (ensuring the plug with the data connections is plugged into the Arduino and that the power only micro USB is plugged into the power socket on the LCD display). Try to run the cables in the extra spaces in the Headset around the screen in order to keep them out of the way.

Lastly connect the HDMI cable to the LCD.

The assembly is now complete.


Connecting headset to PC and setting up software

To connect the headset to your PC do the following:

  1. Plug the DC adapter into mains power.
  2. Plug the USB connector into an available USB port in your PC.
  3. Connect HDMI cable into and available HDMI port on your PC graphics card (You can use a DVI port with an adapter)

Go to display settings and click on detect displays, then set Multiple displays to “Duplicate these Displays” and make sure your resolution is set to 800×480.

Open up Tridef3D and start-up a game.

You might have to play around with each individual games graphical settings as well as mouse sensitivity to get the best results.

For future enhancements I will look at getting a higher definition LCD screen and also work on head movement tracking by using infrared LEDs and a Wiimote (Wiimote used as a IR Camera).

And there you have it a DIY VR Headset for $80. Give it a try.

Here is a short demonstration video:

DIY VR Headset for $80 (DIY VR Part 2)