Introduction to Multi-Threaded, Multi-Core and Parallel Programming concepts
In this article I’m going to present a gentle and modernized introduction to multi-threaded and parallel programming. While there are no concrete examples in this overview, I’m going to cover the general concepts and terminology, as well as an overview of the tools available to you as a developer to leverage multi-threaded techniques in our modern era of programming.
What is multi-threaded programming?
Single-threaded programs execute one line of code at a time, then move onto the next line in sequential order (except for branches, function calls etc.). This is generally the default behaviour when you write code. Multi-threaded programs are executing from two or more locations in your program at the same time (or at least, with the illusion of running at the same time). For example, suppose you want to perform a long file download from the internet, but don’t want to keep the user waiting while this happens. Imagine how inconvenient it would be if we couldn’t browse other web pages while waiting for files to download! So, we create a new thread (in the browser program for example) to do the download. In the meantime, the main original thread keeps processing mouse clicks and keyboard input so you can continue using the browser. When the file download completes, the main thread is signaled so it knows about it and can notify the user visually, and the thread performing the download closes down. Read more…
“Quite Interesting” Media Round-up: 13th May 2013
In programming…

Figure 1. That’s some mighty cock and balls you got there bro
I came across a pretty sweet (and free) tool called CyberDuck. It lets you connect to FTP, WebDAV, Amazon S3 and Google Drive sites (among others) from a unified interface, which is pretty neat and allows you to consolidate all those file transfer apps on your hard drive a bit.
In mathematics…
I discovered the site PurpleMath which has a really excellent repository of algebra tutorials and exercises for any student or professional who needs a refresher.
In technology and IT…
This month the 75% of the UK electorate who didn’t vote for UKIP are wondering what their country has degraded into, while the other 25% are excitedly preparing for a return to the Dark Ages. Fortunately, it’s not all bad news: an image was spotted by a keen Redditter of the Mars Spirit rover drawing a giant penis on the surface of Mars; eloquent reporting as always by The Register, although the editors at Space.com were significantly less amused by these chenanigans than us luddites. In other extravagance that greatly relieved my personal travel woes, Google’s own private airport terminal is now under construction after being approved on 18th April. It’s alright for some, but poor old Kim Dotcom hasn’t been so lucky as he continues fighting the charges against him re: MegaUpload and copyright infringement. Remember when he made the MegaCar in 1999? Oh how the mighty have fallen. Read more…
“Quite Interesting” Media Round-up: 29th April 2013
In a month where Margaret Thatcher died shortly after the late Venezuelan president Hugo Chavez, and the Boston marathon got bombed – doubtless leading to a renewed and never-ending security tirade from our friends across the pond, I thought it would be a good time to start a new regular column highlighting interesting media I’ve found while trawling around the web and my satellite channels (read: The Pirate Bay), with of course, an emphasis on programming, science and gaming. Read more…
LightSwitch for Games Part 1: Introduction to Building your Game Data Network with LightSwitch
NOTE: Although this series is aimed at small game developers, it is equally applicable to anyone wishing to learn how to use LightSwitch.
Most modern video games have an online component nowadays. For games with online leaderboards, stats tracking, world-viewable awards and achievements, online virtual currency and distributed non-real-time turn-based games (for a very simple example, play-by-mail chess), a server is required with a database to store the information, and some way of retrieving and updating the data in a secure manner.
A typical and traditional way to achieve this is by using PHP and MySQL: you merely create tables in the MySQL database for the information required, and provide a series of PHP scripts or endpoints which can be passed data via HTTP GET queries (standard browser URLs with no additional data except that in the query string), and return the results – typically either the requested data, or a flag indicating whether the data was updated successfully or not. Your game code calls these endpoints as required to query and update the server-side data. Read more…
Tetris: Adding polish with music, sound effects, backgrounds, game options, an intro sequence and other tweaks
Our previous version of SimpleTetris is working quite well as a single-player game, but lacks the professional touch. In this article, we’ll look at:
- how to make pausing and unpausing the game also pause and unpause all of its subsystems
- how to add music and sound effects and tie them into game events with SimpleFMOD (a library developed in another series on this web site which uses the well-known FMOD SoundSystem to produce audio – see the first part of the FMOD series for more information on how to use FMOD)
- how to make an event-triggered throw-away animation using Simple2D
- how to use bitmap images (sprites) as animated backgrounds
- how to add game options which can be loaded and saved
- how to add an intro sequence and a credits page
Most of these changes can be slotted in without any changes to the game logic, but there are a few gotchas and some little tweaks we can apply to make things better. I’ll note these below.
Download (SimpleTetris 1.41): Source code | Executable
For comparison, also have on hand the executable for the previous version of the game (SimpleTetris 1.31).
I strongly recommend that you run both versions and do a side-by-side comparison of the behaviour while working through the sections below, then hopefully the changes described will make sense more easily. Read more…
Simple2D 1.10 now available
A new major release of Simple2D is now available (the download link can be found at the bottom of the page).
Version 1.10 introduces improved scene management, improved scene objects and user interface objects, object groups, customizable window resize and full-screen behaviour, more logical event dispatch, new time-based animation functions and a number of bug fixes. Read more…
C++ Class Hierarchies Crash Course: Derivation (“is-a”) vs Composition (“has-a”), and Is a Square a Rectangle?
In this article I’m going to rattle over some basic design choice dilemmas you might face when trying to organize classes into a hierarchy. We’ll look at standard derivation (the “is-a” relationship), composition (the “has-a” relationship), when to use which, and also touch briefly on interfaces and private inheritance.
Pre-requisites you should know before reading:
- how to define a class in C++
- what a constructor is and how to define one
- the difference between public and private members
The “Is-a” Relationship
Is a square a type of rectangle? Is a rectangle a type of square? Or is a square merely a rectangle with a certain set of properties (identical width and height)? Are circles and rectangles both types of shape, or are they even related at all? The answers to these questions have nothing to do with your natural intuition or experience from the real world (although that helps sometimes), but rather, what you are planning to do with them in your code.
