Category Archives: Programming

Rapid Game Prototyping: Tips for Programmers

proto2

In November 2013, two colleagues* and I made 30 games. Although I have done some game prototyping before, working on so many games in such a short period gave me some insights I did not have before. As I said to a friend, it’s like watching a television series in a few days, instead of watching each episode week by week – you just see different things.

In this article, I collect some of these observations in the form of a set of tips. I kind-of assume you are already familiar with the classical How to prototype a game in 7 days, which describes prototyping from a more general point of view. In some ways, this is a programming-specific extension to the ideas presented there. Continue reading

How to Choose Colours Procedurally (Algorithms)

colours

Changing the colours of art can be a great way to increase the amount of content in your game, and add variety and richness. It is relatively easy to implement. What is not always as easy is to get a set of colours that looks nice. This article gives some ideas for choosing colour palettes that look nice. Continue reading

Implementing and Debugging the Perlin Noise Algorithm

perlin_header2 One of the most visited articles on our site – How to Use Perlin Noise in Your Games – also caused the most problems. The pseudo-code contained an alarming number of bugs (one of the nastier ones is depicted above), which made it difficult to implement. Readers pointed out these in the comments, and so helped to make the pseudo-code progressively more correct. But even so, some operations remained unclear, so that I finally decided to replace the pseudo-code with real and tested code. I really hope that all bugs have now been squashed!

In the spirit of this extermination effort, this article gives some pointers to get a version of the algorithm up and running as quickly as possible. It is an extension of the original Perlin noise article, and refers to the code now presented there.

Continue reading

Bézier Path Algorithms

In the article Bézier Curves for your Games: A Tutorial, I introduced Bézier curves and Bézier paths. In this tutorial I provide some algorithms useful for working with Bézier curves: determining the length of a piece of curve; interpolating a set of points with a Bézier path; and reducing a large point set to a smooth Bézier curve. (Image by snuffyTHEbear).

Continue reading

Box2DFlash Tutorial

More and more games are using dynamic physics to add to the gameplay or as a core element of the gameplay. Box2D is a popular and powerful physics library that is considered to be one of the best 2D physics libraries around. It is used by high profile games like Angry Birds and Crayon Physics Deluxe. This tutorial will focus on the Flash version of Box2D and assumes that you have basic experience with Flash and ActionScript 3. If you are new to Flash, check out Nandrew’s excellent Flash tutorial.

Continue reading

Starting Small: XNA Framework Guide

In this instalment of the Starting Small series, we look at XNA (XNA is Not an Acronym) – a set of tools from Microsoft for developing games. The reasons this tutorial is focussing on XNA are simple: it is easy to use (when you know a bit about it), and it can be used to develop for Windows, Xbox and Windows 7 Phone. With the arrival of Xbox LIVE in South Africa, I’m sure that many developers will want to try their hand at developing for these platforms.

Continue reading

Quadtrees: Implementation

(This article originally appeared in Issue 26 of Dev.Mag)

Quadtrees are 2D data structures, useful for efficient representation of 2D data (such as images), and lookup in a 2D space (where are those monsters?) In this tutorial, we focus on the implementation of quad trees that represent 2D data efficiently; that is, where quadtrees can be used to compress data.

Continue reading

Using graphs to debug physics, AI, and animation effectively

Anyone who has stepped through code or has waded through endless lists of variables or log entries knows that these aren’t always the best ways to find certain kinds of bugs. For example, when a physics-controlled object does not behave as expected, looking at how the values of variables change on every frame can be a painfully slow and frustrating process – if you are lucky enough to be able to break into the debugger at the right time.

However, when you display the values of variables graphically, you can instantly see trends and relationships. This makes it much easier to spot errors and to track down what caused them. Sometimes it can even highlight problems that you were not aware of. Continue reading

Make your logs interactive and squash bugs faster

With modern debuggers and testing tools, the need for logging is not as great as it once was. But there are times when debuggers won’t do (for example, on players’ machines, or when hunting down bugs that occur sporadically). For these instances, logging can still be useful, and with modern web technology, you can build a powerful logger that is more than just an endless stream of text.

Continue reading

Guerrilla Tool Development

I have a weak spot for cool game development tools. Not the IDE, or art or sound tools – I mean the level editors, AI construction tools – those that developers develop specifically for their games. Those that you know could help you multiply your content, and craft your game just a little bit better.

Continue reading

Starting Small – Python and Pygame

Welcome to the Starting Small series. The aim of this series is to take a programming language that you hopefully know a bit about (enough to feel comfortable using) or that you want to try out and show you how to use it to make games. The language that this tutorial focuses on is Python using Pygame.

Continue reading

Easy Programming with Python

This article originally appeared on NAG Online.


Code in Python, go to outer space. A simple process, really.

Do you really, really want to become a game programmer? Do you really, really have no idea how to start? Try some Python! This easy and simple programming language is not just a great springboard for people who don’t know much about coding: it’s also a tool that’s gained a considerable following in South Africa over the past few years, and is famously endorsed by Mark “can haz astro-monies!” Shuttleworth. Continue reading

Getting More out of Seamless Tiles

We have used tiles to decorate our living spaces for more than 4000 years. Tiles have several properties that make them attractive for use:

  • they can be mass-produced;
  • they are easy to build with (because of their geometric properties); and
  • combinations of tiles lead to a huge number of decorative options.

Early game makers recognised that these advantages of tiles also apply to tiles in computer graphics, and using tiles was (and still is) a popular way to make game graphics.

Continue reading

Poisson Disk Sampling

This article originally appeared in Dev.Mag Issue 21, released in March 2008.

One way to populate large worlds with objects is to simply place objects on a grid, or randomly. While fast and easy to implement, both these methods result in unsatisfying worlds: either too regular or too messy. In this article we look at an alternative algorithm that returns a random set of points with nice properties:

  • the points are tightly packed together; but
  • no closer to each other than a specified minimum distance.

Continue reading

How to Use Perlin Noise in Your Games

(Originally appeared in Dev.Mag Issue 20, released in February 2008.) Perlin noise is the foundation of many procedural texture and modelling algorithms. It can be used to create marble, wood, clouds, fire, and height maps for terrain. It is also very useful for tiling grids to simulate organic regions, and blending textures for interesting transitions. In this article I will explain how to implement Perlin noise, and how you can use it in your games.

Edit 19 June 2011: The examples were originally given in pseudo-code. Unfortunately, these contained some mistakes, which many commenters helped to sort out. I finally replaced the pseudo-code with real C#, copied-and-pasted from a working file (which you can download below). Hopefully it will make the algorithms easier to understand. Note that efficiency was not considered at all; the code is a fairly direct translation of the original pseudo-code.

Edit 19 May 2012: I always thought the cloudy noise described in this article is called Perlin noise. Turns out, it is not. The worst is, I cannot say with hundred percent confidence what it is called. Fractional Brownian Motion (fBm) seems to be the most likely candidate, but to be honest, I am still figuring out whether my simulation is technically equivalent to the ones described on Wikipedia (nevermind that Wikipedia may also have it wrong).

Real Classical Perlin noise, and simplex noise, can also be combined, just like the “smooth noise” is combined in this article, to give cloudy noise. This is what confused me (and others, I presume). Cloudy noise generated from Perlin noise looks much better (it is not as blocky), although for many purposes the cloudy noise described here will work fine. So if you are interested in how to make cloudy noise… read on. I will follow up at a later stage with more concrete information about real Perlin noise.

Continue reading