The Gilbert-Johnson-Keerthi (GJK) algorithm is an efficient method for computing the distance between two convex shapes. It has become a popular method for real-time 3D collision detection. While less commonly used for 2D collision detection, the GJK algorithm still maintains several of its advantages. Its biggest disadvantage is that the algorithm can be conceptually difficult to understand (although it is easy to implement). This tutorial will explain how the GJK algorithm works in detail and demonstrate how to apply it to 2D collision detection.
Author Archives: Eric
GJK Algorithm Demo
The Gilbert-Johnson-Keerthi (GJK) algorithm is a method that can be used to find the minimum distance between two convex objects. The algorithm is often used for 3D collision detection in video games. I decided to write up a 2D implementation to try it out. So far, I have been very happy with the results. I am now planning on replacing the existing collision detection in the Entropy Engine (line-line intersection testing), with the GJK algorithm. I will also write a tutorial on the algorithm in the next week or so. In the mean time, you can see it in action here.
Entropy Engine – Basics
Entropy Engine provides several classes to simplify the creation of Java based games. This tutorial will describe how to use those classes. Included is how to create a game, how to control the game loop, and how to use the input system. More information on the Entropy Engine can be found on the Entropy Engine page.
Game Engine Design – Component Based Entities
Component based entities are becoming increasingly popular. They are a design pattern that can greatly improve the maintainability and flexibility of your game code. This tutorial will describe what component based entities are and how to design them. A Java implementation is provided which can easily be translated to other languages.
Game Engine Design – A Simple Game
Now that we have created a game loop, window, and input manager, we can create a very simple game. This will be a short tutorial, but will demonstrate the use of the components we have created. We will begin by creating the main class AsteroidsInfinity. It will extend Game, the window manager we created earlier.
Game Engine Design – SVN
I have set up a SVN repository at Sourceforge.net. If you have an SVN client installed (such as TortoiseSVN), you can check out a copy of the current game engine code. The repository location is https://entropyengine.svn.sourceforge.net/svnroot/entropyengine/trunk/entropyengine. I will also be packaging various releases to go along with the tutorials, so if you don’t want to use SVN you can simply download a .zip file. A word of warning, the game engine is still in early development and may not be the most stable. If you have any comments or questions, let me know.
-Eric
Game Engine Design – Game Window
Now it is time to create a window for our game. In this tutorial, we will extend the game loop class from earlier. The goal is to create a simple window for drawing. This tutorial is mostly Java specific. If you are using a different language or API, you will need to handle window creation differently, though you may still want to extend the game loop in a similar way.
Game Engine Design – Input
This tutorial will develop a system to handle game input. We will go over the features we want in our input system, and some concerns regarding input will be addressed. We will then implement an input system for the game engine. Unfortunately, user input is generally platform and API dependent. The implementation provided here is Java AWT specific, but the information provided on the first page is intended to be as general as possible.
Game Engine Design – The Game Loop
This tutorial will cover one of the most basic components of a game, the game loop. The game loop is what actual drives your game. It manages the calls to your logic and drawing functions. While doing this, it performs the vital role of maintaining a consistent game speed (also called a logic rate). Creating a game loop is not always an easy thing. Many newer programmers get stuck on this. This tutorial will explain what a game loop is, how to create one, and what are some common pitfalls.
Game Engine Design – Logging
The first part of the game engine I will cover is the logger. It may not be the most interesting, but most of the other components will need access to the log so it needs to be finished first. Logging is very important in all but the simplest of games. During development, it provides feedback about the current state of the program. Later, once the game is released, it is your only source of feedback on the game. This information is invaluable when debugging.
