Wednesday, January 31, 2007

Java "Interval" Class

One of the most useful classes I've ever written is this Interval class. Games always have a main game loop, which gets run every game cycle. However, often you don't need something to be done every cycle, such as the AI re-examining it's environment. For this reason I wrote a simple Java class which is used in the following way:-

Interval check_env = new Interval(1000); // Millisecs

while (game_looping) {
if (check_env.hitInterval()) {
// Do slightly more involved stuff.

It's not the worlds best class ever, but I find myself using it all the time. Here it is:-

public class Interval {

private long last_check_time, duration;

public Interval(long dur) {
this.duration = dur;
this.last_check_time = System.currentTimeMillis();

public boolean hitInterval() {
if (System.currentTimeMillis() - duration > this.last_check_time) {
this.last_check_time = System.currentTimeMillis();
return true;
return false;


Wednesday, January 24, 2007

GTA Autopsy

I was getting a bit worried that my latest game Passenger was starting to turn into another GTA clone. Which it is. But it's my GTA-clone, and I can claim I wrote it! However, it also gave me reasons to think about the flaws in GTA that I can hopefully improve upon, and there are a few. Off the top of my head:-

* The camera - They slowly improved this from GTA3 - 5, but it's still a pain. Try running down the road, stop, turn 180, and then run back. You can't see where you're running! What's the point in that? It ruins the immersion as you realise you are playing a game and must think about how to get the camera to spin round.

* Targetting - I prefer direct control over my targetting, old-skool shoot'em-up style. Simply pressing the "target" button and letting the computer target for you takes all the fun out of it. Where's the skill?

* Character movement - This is actually quite cludgy. I've played San Andreas all the way through, and I think the last mission is probably the most frustrating, which is a combination of probably all these points but mainly this one. If you compare the slick control of, say, a Mario game (sorry), you can see that there is no fine-grain control. It's just a case of move, spin round, press target, shoot someone, hope they don't kill you first, and repeat.

* Frustrating missions - I realised a long time ago that most of the missions, IMHO, aren't that much fun at all. They are more frustrating than anything, and the only incentive (and it is a strong incentive) to complete them to continue the story. And I have nighmares about the missions that involve radio-controlled vehicles.

Needless to say, GTA is an amazing game, but the most fun I have out of it is by playing simple "antagonise the police" games. Anyway, I won't let Passenger end up with the same criticisms.

Friday, January 05, 2007

Multi-Player On-Line GTA Variant

That snappy name is the unofficial title of my latest programming adventure called Passenger. It was originally intended to be a remake of Turbo Esprit (a Spectrum game from about 1984), but after developing it, I discovered that due to the type of game Turbo Esprit is, if you write an updated version, you pretty much end up with GTA.

I'm trying to avoid copying GTA, but it's hard trying to think of any new gameplay aspects that they haven't included. Still, it's pretty rewarding to write a free multi-player GTA, even if it's not quite as good (yet).

Anyway, feel free to give it a whirl and let me know what you think.