Monday, February 18, 2008

Blindingly Obvious Java Tips #2

Todays tip is all about getting your game to run at a consistent speed. You may not think it a problem on your new game, since you probably crammed in enough features to keep the CPU busy for just the right amount of time, but once you try and run it on a Cray (since surely that must have a JVM??) you may find it slightly unplayable.

So, to stop it running too fast: First, define a variable of type "long" at the start of your program for how long you would like the program to take over each game loop. In the example below, I've chosen the name "LOOP_DELAY" for this var, and I usually give it a value of around 25. You'll probably want to tweak this amount. Also, declare another long called "start_time".

Anyway, at the start of your "game loop", write something like:-

start_time = System.getCurrentTimeMillis();

This will store the current time when the computer started the game loop. Finally, at the end of your game loop, write something like:-

long wait = LOOP_DELAY - System.currentTimeMillis() + start_time;
Thread.sleep(wait);

(You'll need to wrap this in a try/catch BTW). This bit of code will make the program pause for a certain amount of time at the end of each game loop, that time being the number of milliseconds you wanted it to take over each game loop, minus the amount of time it took to actually process the code in your game loop. This will cause each game loop to take a consistent amount of time, assuming that the time it takes to process the code in the game loop isn't longer than the time you want it to wait for!

Friday, February 15, 2008

Announcing Laser Tactics!

If you've read one of my earlier article, you'll know that I've decided to "re-released" Nuclear Graveyard under a new name - "Laser Tactics" (kindly suggested by Charlie). And now I've finally got round to it. I've given it a few more tweaks, and I'm pretty pleased with it all. I've taken a few more screenshots to celebrate, which I'll be sticking on the website as soon as I can.

The only problem with it is that it's not an FPS, and it's not turn-based, and most people expect a game like this to be either one or the other. If anybody reading this decides to give it a go, please bear this in mind: Your unit's APs are replenished in realtime!


Thursday, February 14, 2008

Blindingly Obvious Java Programming Tips #1


(This is number #1 in my intended series of Programming tips for Java. They are probably blindingly obvious to most people, but they have passed me by until recently, and it doesn't do any harm to mention them in case anyone else has missed them to).


Daemons

Todays tip is all about setting threads as "Daemons".

I used to have a problem in my games that used multiple threads, in that it was very hard to get them to actually end. Even when all the windows were closed, there was still a process running in the background. I usually fixed this by adding a "System.exit(0);" to the code when I wanted it all to end, but this is certainly not the best way to go about it.

A Java program ends when there are only "daemon" threads running. This means, in short, that any thread which isn't what you would call the "main program thread" should be marked as a daemon so that it ends when the main program thread ends. This is simply a case of writing "mythread.setDaemon(true);". Incidentally, threads are not daemons by default.

Wednesday, February 13, 2008

Programming Affects the Mind

I've long suspected that spending too long programming affects the way the mind works, and I've finally come across a quite-good example:-

My wife innocently asked me if our car boot was locked. Being a programmer, where accuracy and logic is paramount, my mind was instantly plunged into a spagetti of possible answers and their respective problems.

Our car's boot (trunk for Americans) can only be opened with a key or by using the lever by the side of the drivers seat. There is no button on the boot to open it if the car is unlocked, which it was. So was the boot actually unlocked? One possible answer is "no", since it couldn't be any more unlocked than it was. However, giving this answer implies that it was possible for her to go out and open the boot, but I'm not sure she knows about the lever (since she's not a driver) and she doesn't have a key, this wouldn't work. So is the answer "yes it is locked", since the boot cannot be opened directly? But this can't be correct, since it is openable without a key, which is presumably the definition of "locked". Is the correct answer "sort of"? No, not if you want to be helpful. Is the correct response to explain how the various boot locking mechanisms work or describe where the lever is? Probably not, since it would take too long.

In the end I just ummed and ahh'd and said I'd open it for her.

Monday, February 11, 2008

The Problem with RTSs

One problem is knowing whether to put an apostophe in the word "RTS's". However, the other problem I have with them is always feeling that it's pointless trying different actions; either they won't make any difference, or it's all down to chance anyway.

I really want to enjoy RTS's, ever since I played what I think is the very first one: Stonkers (not Dune II!). I've not played many of the later ones, but I've played C&C, StarCraft, Age of Mythology, and quite a few free ones, and even written my own.

The typical scenario goes like this: I select a group of units, move them towards the enemy, and err, repeat. All I can do now is watch them do battle. Maybe my units will win, maybe they won't. Should I try some newfangle tactics? Does it make any difference if I have some units on the left side of the enemy and some on the right side? Or maybe I should build a tank instead of two foot-soldiers? Is it better to have a tank than two footsoldiers? I don't know. All I know is the units keep shooting at the enemy and eventually some of them die. The tank is more powerful but has a slower shot rate, but I can't be bothered to check the "stats" to see if the more powerful gun with a slower shot rate is better than two weak guns with a faster shot rate.

I might be fighting another small skirmish in another part of the map while this is going on. When I go back to the original skirmish, some of my units have survived and the enemy seems to be dead. Or did they retreat? And if they did, how much damage was inflicted? Who knows. I'm no closer to knowing what the best tactics are, or if it makes any difference.

So by now I've lost interest and decided to play an FPS or something.

Friday, February 08, 2008

Name of the Game

I've been toying with the idea of changing the name of my game Nuclear Graveyard (again), since it has nothing to do with anything nuclear, and even less to do with graveyards. The reason I chose it was because I got a DynDns domain name, and I chose "ng" as the prefix to the standard domain "game-host.org". I chose NG as I was thinking of the phrase "network game", since at the time I didn't have any idea what I wanted to do with it! I then decided to give my new (at the time) game the initials "NG", and the rest is history.

I have toyed with the idea of giving it the ridiculous name "Space Nazis", just to see if it would perk up interest. However, this would be misleading as most people would expect some wacky platformer or something, whereas Nuclear Graveyard is a 3D multi-player "serious" strategy FPS game.

I might just change it back to its original name "Laser Squad 3D", since that sums it up perfectly if you remember the original Laser Squad game. I think it's a bit of a cliche to add "3D" to the end of a game's name though, which is why I changed it in the first place.

So, watch this space...

Thursday, January 31, 2008

A* Algorythm in Java - Download

I wrote this code a while ago, and I've finally got round to putting it here for public use. It's the A* path-finding algorythm, nicely self contained and ready for use. It can run in a thread if required, and to use it, you can simply write:-

AStar my_astar = new AStar(mymapclass);
WayPoints route = my_astar.findpath(start_x, start_y, end_x, end_y, b_run_in_thread);

Your
mymapclass must implement the IAStarMapInterface (included), which has 3 methods: getWidth(), getHeight() and isTraversable(). This tells the algorythm where it can and can't go. The class WayPoints is just an ArrayList of Points, giving the route.

I've used this code in all of my games (that require pathfinding) like Nuclear Graveyard and TremulousHulk.

(For those not in the know, the A* algorythm basically finds the closest path from one co-ordinate to another, taking into account blocked points.)

Monday, January 28, 2008

Tiny Web Server

There seems to be a durge (if that's the right word) of web servers called "Tiny Web Server", all vying to be the smallest web server. And now there's another one! I don't think it's the smallest, but it is a full web server for delivering static pages and documents.

It's written in Java, and the source comes to 23K. It should be pretty easy to extend to make it write dynamic web pages, so it should be ideal for starting your own web server project, or just giving you an idea of how web servers work. Or how not to write code. Take your pick.

It's available via SVN here. (That's svn://www.onlinegameplanner.co.uk/TinyWebServer).

Wednesday, January 16, 2008

Originality is a Curse

...That's probably why most games companies still churn out mostly FPS's and endless sequels to those FPS's.

I've written a game called Nuclear Graveyard which (IMHO) has a bit of originality: it's what I call pseudo-realtime. This means that rather than be proper realtime, it uses action points (e.g. walking forwards costs 1AP) but unlike most games that use APs, the player's APs are replenished automatically as both sides use them up.



Unfortunately, when most people play it, they don't seem to read the instructions, and assume that it's either a normal FPS ("why can't I move?") or a normal turn-based game ("How do I end my turn?"). I can't blame people for not reading instructions - who does? - but I've tried my best to make it self-explanatory, and included a tutorial, but to no avail. What do I do?

Friday, January 11, 2008

Multiple Platforms, Multiple Databases

SQL Enterprise Manager (or SQL Server Studio, as M$ like to keep changing the name) isn't a bad program, but obviously it only works with MS SQL, and only on Windows. Since I use MySQL, PostgreSQL, Oracle and MS SQL on Windows and Linux, I've been looking for a single program that can handle all of these databases, and I've found one: Aqua Data Studio.

It's written in Java (though there are other versions available) so it runs on Windows and Linux, and it easily connects to almost every kind of database, allowing you to do all the impotant things that SQL Server Studio does, like view the tables, edit the data, run queries etc...

I'm not affiliated with Aqua Fold in any way, but I thought I'd mention a program that is really useful and pretty good. It's free for personal use as well.

Wednesday, January 09, 2008

Domain Name Front Running

I wondered if any companies do this (i.e. you search for a domain with the intention of buying it, and the company that you use to search for it buys it up, knowing that you want it). And yes! Of course it happens...

Friday, January 04, 2008

My New Language

I have finally abandoned my attempt at a new Lisp-like language. I don't think I realised how hard it would be. Converting a text file of my new language into an AST (an active syntax tree) was the easy part. The hard part was storing variables (globals v locals, scope, identically named vars overriding each other, etc...) and calling functions (i.e. replacing the params in the function) among other things.

I should have planned it all better as I was also going round in circles with my language definition: I was changing it to fit one circumstance, but then forgetting why I'd done that, and then I'd change it back again to fit the original circumstance.

However, the final nail in the coffin was my thought "what am I going to do with it when I've finished?" It obviously had no IDE, barely any libraries, no debugging facilities, probably lots of bugs, and probably lots of flaws in the design. Why would I, never mind anyone else, choose to use it when there's plenty of other better languages out there?

Still, it's given me a new insight into how languages (might) work, and hopefully made me a better programmer. Now onto my next project: a mega-multithreaded program, where every little aspect has it's own thread. It's how the human body (i.e. cells) work (I think) so it must be a step in the right direction. And with all this talk of parallel programming, it can't do any harm for me to fail at that as well.

Thursday, December 13, 2007

Don't Buy Western Digital Hard Drives

More political posting I'm afraid...

Anyway, to get straight to the point, Western Digital HD's are crippled with DRM to prevent files with certain media extentions (e.g. AVI, MP3) from being shared across network drives. Even if they are your own creation! And the name of the software that does this? "WD Anywhere Access". You couldn't make it up!

Friday, December 07, 2007

My Programming Adventure - Is the journey nearly over?

I've alluded before to the fact that I sometimes think of my time spent programming as an adventure, looking for the reason why I program and what I hope to achieve. (I'm talking about my hobby programming of course - I do my profesional programming to pay the bills).

Several times I've been in the middle of writing one of my games, and suddently realised I'm not actually enjoying writing it. Or I've finished a game and realised it's not that much fun to play, or I think it is but the ROTW disagrees.

However, I have now found my holy grail. I've written a small, simple and (AFAIK) original puzzler called Chain Reaction. It's pretty addictive, but what has caused it to really take of here where I work is the high score table. People are falling over themselves to try and beat each other, and I'm loving the fact the people are telling me they hate the game because they're spending too much time playing it but they can't stop! I may be egotistical, but I think it's the kind of praise and recognition I've been looking for all these years.

Thursday, December 06, 2007

New Language Update

Here's a tip for anyone who's thinking about writing their own language - plan it first. I know I should have. I've got a reasonable understanding of how Lisp works (i.e. evaluate everything inside the brackets recursively, and then process it) but I made some silly mistakes...

..Like evaluating the brackets each time I read them. For example, the program:-

(defvar lst (quote 1 2 3) ; <- "lst" now contains (1 2 3), correct.
(print (lst)) ; Error! I've processed "lst", but the function "1" (i.e. the first item in the list) is (obviously) unknown!

This is just one example. I'm going to start again. I've learnt a lot from my mistakes though, and my aim is to have a language with the best Lisp features like Macros, but more practical with simple functions to connect to databases etc...

Thursday, November 29, 2007

My New Programming Language - "Harry".

Being a programmer who has no fear of programming a disaster, I've decided to write my own programming language.

"Madman!" I hear you cry, but no, seriously. And on the face of it, it's not that difficult. On the face of it, it's just a case of reading a text file and turning that into "symbols", which your interpreter/compiler converts into something existing, whether it's Bytecodes or good old machine code.

My language is called "Harry", and is similar to Lisp, since everyone seems to rave about it, and I've been quite impressed with it. However, there are a few (minor) problems with Lisp, which no doubt people will take me to task for. Here's my : it's not standard enough (there seem to be lots of variants), and it's not very practical (in order to do something like graphics or databases, you need to find libraries).

I've written the interpreter in Java for platform-independence. It's still in the development stage, so no download yet. The current problem I've got is functions and the variables contained within. What happens if a function names a variable with the same name as a global variable? And scope is a problem, i.e. "unsetting" the variable once the function has finished, so the global var becomes available. But what if the function calls another function? And recursion? And what about if a parameter to the function has the same name as a variable?

Anyway, to whet your appetite, here's an example of the code (which should be self-explanatory):

; Add, eq, print
(print (eq 2 (+ 1 1))) ; returns 1

; Set
(set lst (quote 1 2 3))

;quote, contains, if, return
(print (if (contains 2 lst)(ret true)(ret false))) ; prints "True";

Monday, November 19, 2007

Why Are Named Parameters Rare?

One of the things that seems common to most languages, even the supposedly better new ones, is the lack of "named parameters". Surely it must have come to the attention of most language designers that having a line like the following is ridiculous:-

// Do some stuff
int x = MyFunction(true, false, true, true);

Okay, it's probably bad programming practise to have something like this, but even a simpler line with just one boolean would be bad. What on earth does each parameter mean? The only way of finding out is to query the underlying function's code, but that defeats the object of having well named functions. I'm still surprised that having named parameters isn't in most modern languages. How much better is the next line:=

int x = MyFunction(foo:true, bar:false);

Here you can see, without having to browse the underlying function, what each parameter means. Okay, this is nothing earth-shattering that will lead to perfect code, but it has to be a step in the right direction.

Thursday, November 15, 2007

Eclipse and Subversion (Subclipse)

I've blogged before about using Subversion and Eclipse - if you haven't installed Subclipse then don't do it! However, I've discovered another problem and solution to Subclipse...

Even when Subclipse is installed, if you have seperate src and bin directories, the bin directory can confuse Subclipse, since Eclipse likes to effectively delete it and recreate it with each build. The solution to this (apart from adding the bin directory to your ignore list) is to not "Scrub output Folder when cleaning projects".

Wednesday, November 14, 2007

New Game - Chain Reaction

And this time it's original! I knocked it up in Java over about a day (though most of that was trying to work out how to turn "bouncing balls into each other" into something resembling a game).


It's called Chain Reaction. Basically, you have to bounce a certain number of balls into each other. The page (just like all my other applets) keeps track of your scores in a global high-score table, which I think greatly improves the competitiveness. And it's pretty addicitve (and hard) to boot!

Tuesday, November 13, 2007

I Bought a Domain!

I've finally bitten the bullet and bought a domain - http://www.onlinegameplanner.co.uk/. My original "default" domain was "ng.game-host.org", which doesn't really roll off the tongue quite as well, and bears no meaning to the content of the website.

Thursday, November 08, 2007

New Project

It's called Survival (at the moment).


[Added 19/11/07] A few other details since the original post was so sparse: it's written in Java and uses jMonkeyEngine to do the 3D.

Tuesday, November 06, 2007

BBC & Microsoft

(This blog is getting a bit political, I know). What happens when an ex-Microsoft employee starts working for the BBC? They develop a Windows-only iPlayer and claim that only 400-600 Linux users visit the BBC site, before hastily correcting themselves after getting it 16,000% wrong.

Wednesday, October 31, 2007

Software Exams! Grr!!

One thing that annoys me a lot are "software exams", where you can become a certified drone of the particular software company, typically Sage or Microsoft. They are a two-pronged attack by the software company on free software, gaining them money (because you have to pay to take their exam) and locks you into their software, since you are more likely to stay with software that you have spent money and time learning.

But they also have ridiculous questions! One of the Sage exams has the question "What is the maximum number of lines you can have on an invoice?" What?? So Sage has decided (either due to their inability to write software that allows as many invoice lines as possible, or their marketing dept. decided that it looked good in a brochure) that you can only have 99 lines on an invoice. And people have to memorise this (and a myriad of other completely pointless facts) in order to pass an exam.

Excuse me if I'm not impressed with anyone who's been stupid enough to take this exam.

Monday, October 29, 2007

Off Lisp

I don't see why Lisp is so great. I wrote a "random movie star selector", and it came up with Tom Cruise.

Thursday, October 25, 2007

Shadowfire Remake

Shadowfire is a classic Spectrum game from 1985, and I'm always surprised that no-one has remade this, since it seems perfect to me. The original game had some great ideas, plot and gameplay, but was limited by the platform. Some modern graphics would enhance it no end.

So I've taken it upon myself to do the remake, which is located here.

Screenshot

I've given it an RTS-style interface. It's still unfinished; at the moment you can walk around, teleport your team in, and shoot the enemies. It currently uses sprites from the original game, which weren't designed to be used in a top-down game, so if anyone could provide me with new sprites that would be good. I've got the code to rotate them to all 8 directions, so you only need to draw one copy of each!

Tuesday, October 23, 2007

Java Threads

Unfortunately, one of the (few :) ) drawbacks of Java applets is that in order to have a consistent game loop, you need to run the main game code in another thread. (I may be wrong here; please let me know if I am). I've blogged before about why threads in any language are a pain as they exponentially complicate a program, not least because variables can change mid-line.

Another problem that I always forget, is that in Java, threads don't access another threads data directly (unless you use the volatile keyword). Forgetting this caused me several hours of frustration and I even wrote my own ArrayList class to try and fix it. Basically, the code in my thread's run() function was accessing the class-level arraylist. But completely failing to affect it! It was calling "arraylist.remove(13)" (say), but after it had run, that object still existed in the list! What was going wrong?!?

Well, I've already said the answer. It was accessing a copy of the arraylist, not the list itself. As soon as I discovered and fixed this, all was well and I could go back to enjoying writing applets again.

Wednesday, October 10, 2007

An RTS that I intend to be a 2D version of World in Conflict

I mentioned this a while back, and against my own advice I've come back to it. Actually, I've already written most of the difficult framework stuff of selecting units, moving them around, A* pathfinding stuff etc.., and just have the fun of adding a proper "game" and features (- classic assumption by programmers that the final stuff is fun/easy). The screenshot is below, and the game itself is here (or it will be by this evening).

I've nicked the graphics from Advance Wars, and although I've never played World in Conflict, I always think it's a good idea to try and copy a game, as it gives you (me) inspiration and something to aspire to. And if I do anything differently, then great, it makes my game slightly more original!

I used to do this a lot back in my Spectrum BASIC programming days - I've written versions of Carrier Command and Populous, among other games, in BASIC using UDG's (remember those?). It used to be pretty easy. Looked awful, mind.

Tuesday, October 09, 2007

Games Blamed for Society's Problems (again)

People have really got it in for games today!

* Manhunt 2 has been banned (for the second time). (Notice that despite the headline and parent's insistence, police said there was no evidence his killer was inspired by the first game). The Government has decreed that I can watch films like Saw and Hostel, but I am not allowed to play Manhunt 2.

* A Games violence study is launched. Despite the fact that there are far more violent films, books, comics etc., it seems that games are the favourite target for blaming as the cause of crimes and bad behaviour. Didn't we have crime before games started getting "realistic"?

Monday, October 08, 2007

Ignoring my own Advice

After deciding to stop writing overly complex games that take up too much of my time and I end up abandoning before I finish them, I suddenly found myself writing an RTS that I intended to be a 2D version of World in Conflict! Arrg! Note to self: Stop!!

To compensate, I decided to write my own version of the highly addictive game Gimme Some Friction. It took me about two hours, and the results are playable here straight away thanks to applet-technology.

Phew! A finished game that's fun! Whatever next? An original game? We'll see...

Thursday, September 27, 2007

Tremulous Hulk

In my effort to single-handidly save Applets from obscurity, I have just finished the first working version of my new RTS applet, called Tremulous Hulk (because I intend it to become like a 2D Tremulous, but have ripped Space Hulk sprites).


It's very basic at the moment, but in true open-source fashion, I have big plans, culminating in something that will take on World of Warcraft for player-base size.

Tuesday, September 25, 2007

Online Game Scheduler

As an exercise in seeing if I could do it, I decided to write a web server several months ago. HTTP seems pretty straight forward in principle, but programming it can get bogged down if you accidentally send too many CR's and/or LF's. Also, closing connections is a problem, since clients like IE and FF often don't bother.

However, it now seems to be working, and I can officially announce what I think is a website with an original idea!

I've called it NewGame, and it's an "online game scheduling service". Basically, users select which online games they play. Then, when one user schedules an online game, all the other users who have selected that game will automatically receive an email telling them to date, time, and server.

I thought of this because a common problem with online games, especially new ones and the less well known ones, is that they are often bare of human players. Online games are brought alive by other players being there at the same time, and hopefully my solution will help this to occur.

As well as that, in order to give the site more content, it also has the latest gaming news headlines courtesy of a randomly selected news site. There are also forums for each game, and in a nod to free games, they are highlighted as such, so players can download and play them straight away. And finally, it's going to be the platform for my latest foray into bringing applets back from the brink of extinction!

Monday, September 24, 2007

Game Instructions Please?

I don't spend all of what little spare time I have on programming. Sometimes I even get to play some games. With this thought in mind, I decided to look through the Ubuntu games repository and see what strategy games were there.

I came across Boson, which I'd given a few seconds of my time to before. After installing it (which, thanks to Synaptec, is so easy anyone can do it blindfold) I started the game.

This is where the problems hit, and this is why I only gave it a few seconds last time. Visually, the game is great; I could only dream of one of my games looking this good. But how do you play it? My first (and probably only) port of call was the website.

Unfortunately, on the website:-
  • There is no link that give the smallest clue that it might lead to some instructions.
  • The link to the FAQ doesn't work.
  • There is a wiki, but that looks like it's purely for the development team. Nothing to do with actually playing the game.
  • Under "Contact us", there are only links to forums and mailing lists and an IRC channel. Sorry, but I haven't got time for any of those. I either want an answer now (or an emailed reply), or I'm just going to play another game, and there are plenty out there. I was going to email them to tell them that the FAQ link doesn't work.
It's a pity really. Like I said, it looks like a really good game, but they are shooting themselves in the foot by not telling anyone how to play it.

Applets Update

An addendum to my previous post: there is one drawback to applets, and it is that no-one takes them seriously, even when they are good.

Even the forums of the excellent Freegamer blog lumps them in the category "Proprietary & Web Games" (with the subtitle "Just in case you really have to talk about them... "!?).
Maybe the problem is that there's so many rubbish games out there? Do a simple search, and you'll probably come across a million versions of Sudoku, and applets that were written back in 1995. However, there are plenty of good games out there.

Maybe what the genre needs is something like Freegamer, but dedicated to online games, to sort the wheat from the chaff. Hmmm...

Friday, September 21, 2007

Applets Are Dead! (again)

Every time the subject of applets comes up, people insist they are dead. Why don't people like them? In one of Joel's latest postings, he mentions applets being dead because they are slow (despite the fact that the thrust of his post - that you shouldn't bother to optimise, but rather wait for technology to catch up - contradicts this).

I think people misunderstand applets. They were not designed to provide banner ads or simple flashy icons. We've got Flash for that (which is why I have FlashBlock installed). Applets are designed for full applications and games that are comparable to any shrink-wrapped software. And if you do compare them to "normal" software, they come out favourably.

The beauty of applets is that you don't need to install anything, but you've got a feature-rich application, or in-depth game, sat there straight away ready for use. And applets are far from dead - there are tons of them out there, and for the time being it's going to be my platform of choice.

Thursday, September 13, 2007

Revelation And/Or Epiphany

I feel like I've had an epiphany. I was at a low, and now I've seen the light.

I'd spent an hour or so on one of my games (Passenger) trying to optimise the map so that if there were (say) four mapsquares next to each other, all of the same type, it just drew one big square. For various reasons it was taking far longer than I expected. (This is always bad news - one thing I've found guaranteed to get me annoyed is when a task takes much longer than anticipated. That's why I now always assume everything is going to take ages).

Anyway, I suddenly thought: "Why am I spending my time doing this? Writing open-source games? I'm not actually enjoying it, I don't get paid, and (to be brutally honest with myself) I don't even play my own games myself, and I don't think anyone else does."

Basically I'd just become fed up with fiddling around with games, trying to fix bugs, optimise graphics etc. etc. The best part of writing a game is before you start, when you have a blank canvas in front of you, and an image in your mind of how amazing the game is going to be. Once reality sets it, it all comes crashing down after you've spent several hours (or days, or weeks) of your time. Even if a game is finished, then what? There are a million games out there all vying for attention. Why should players spend any time on mine, when it's obvious to anyone that there are better games out there?

Anyway, after a few days of thinking about it, I have come to a solution - Casual Gaming(tm)! Casual Games are much easier to write, and also it means I can play against my colleagues at work, and gain instance gratification to know that the game has brightened up their lives.

My first casual game was (another) version of Tower Defence (yes, not very original). It only took about 3 hours to write, and being a Java applet, it means it's very accessible. In fact, you can play it here. (You do need to log into the website I'm afraid though, but I may change that).

Programming "casual games" means that I can spend far more time designed and tweaking the games and far less time on boilerplate programming and sorting out bugs. And get back to enjoying writing games.

Thursday, September 06, 2007

Common Game-Programming Mistakes #34 & #35

* When looping through the sprites in your game to check for collisions against each other, you check a sprite for collision against itself, which is why the sprite always collides with something immediately.

* Also, forgetting to implement special code to ensure that two sprites that shouldn't collide, don't. Typically, when a sprite shoots a bullet, the bullet will start on top of the shooting sprite, causing a collision immediately when the bullet is fired.

Friday, August 24, 2007

Sun is Java's Worst Enemy

I'm a programmer, and I've been programming professionally for 12 years, 8 of those using Java. But even I find it hard and confusing to download Java! So how's a layman supposed to do it, if all they want to do is play a game that requires Java?

I'm trying to download it to a PC now. Here's the steps I take (bear in mind I'm impersonating a layman here):-

* First I type in "Java" into Google. Oh good, the first result is a link to java.com.
* At java.com, there's a nice big link saying "Free Java Download". I click on it.
* Oh, this page says it's for Firefox/Mozilla. I don't want any kind of browser plugin, I want to be able to run programs on the desktop!
* Oh, there doesn't seem to be any other download link, apart from a small one at the top of the page, and that only takes me to the same "browser plugin" page.

* Let's try java.sun.com. There's a link to Java SE in the "Popular Downloads" list.
* What's with all the JDK's? I just want the runtime? (Though, being a layman, I have no idea what JDK, JRE, or "runtime" mean anyway).
* Aha, I've found a link to "Java Runtime Environment (JRE) 6 Update 2". Update? I haven't even got Java to be able to update it? Does it contain Java and the update? If so, do I still need "Update 1"? Who knows. I'll download it anyway. What hell, I've spent too long already.
* The download page has two links for Windows; one "online" and one "offline". I'll choose the "online" download, as it's only ~400Kb. There seems to be a tickbox to the left of it. Do I tick this? No, I'll just click on the link.
* Oh, I need to accept the licence agreement. Okay, done. Now I click on the link again.

You get the idea. By now of course, the user would have just gone onto something else that doesn't involve Java.

Wednesday, August 15, 2007

Overcoming Lack of Talent

Writing games while having no graphical talent, as I do, is a constant struggle of imagination vs reality. In my head I have ideas for great arcade adventures with whizz-bang graphics. Then I come back down to earth and remmeber that I can't draw a matchstick man without it looking like it has a limp. And it's always been the same even when I used to write stuff on the Spectrum (though in those days people's expectations were lower as the competition wasn't up to much either). Nowadays, when I see some of the amazing free (and amazingly-free) games, my heart sinks as I realise that I'll never be able to produce something just as good.

But with every problem comes and opportunity, and I've thought of a way I can get round my pseudo-disability, and that's to concentrate on the one advantage I do have - not sucking at programming (I think).

To cut a long story short, I'm going to design and animate 3D models using programming, in ways that would (I think) prove hard to do using a 3D modelling package.

And this is my very first attempt after about an hour of prog'ing away:-



Okay, so they look like Space Invaders that have learnt to walk, but it's my first attempt, and should go someway to showing what I want to achieve.

Monday, August 13, 2007

Gameplay Vids

I finally got round to creating some gameplay vids. Having these is an excellent idea (and I'm probably the last person to latch onto this) as it gives people an idea of how the game works. My first candidate for this is Nuclear Graveyard, as I think it's complexity puts a lot of people off playing it.

Here's a [very small] video from The Assassins mission, just as da boyz are about to burst into the house. It's only 30 secs.



On a slightly less happy note, development was stalled today because I made the mistake of installing Oracle's client software, which in turn installed no less than 3 (count'em!) seperate Java Runtime Environments (?), all of which were version 1.4 or less, and all meaning that most of my Java software suddenly didn't work. It only wasted about an hour of my time in working out the problem and solving it. So thanks a lot, Oracle - not! I spend a lot of my time disliking Microsoft, but it seems to me that most software companies are just as evil, but on a smaller scale.

Thursday, August 09, 2007

Note To Self: Playtest!

I have a very short interest span in games, and especially short for my own games. This is my excuse for poor/zero playtesting.

I just move onto a project I started a while back called DangerMan ( a platformer with weapons) since I've got bored of my latest project (though I will return to it eventually). And what a pile of bugs I found after only playing for only a few minutes!

Here are a few highlights:-

* If you shoot a rocket, you die straight away as it explodes immediately.

* Even when I got the rocket working, it destroys the scenery, but still draws it, because everything was being drawn twice in two different ways.

* The menu system gets confused with itself and you have to restart the program after a couple of goes.

* There was no mechanism for actually finishing a level (that I could tell).

I pity anyone who downloaded this game! It was completely unplayable, though it was at version 0.13 or something. I have now corrected these bugs and released a new version.

This leads me to my next thought - what's the point of releasing a game until it's finished? I suppose the source code is there for other people to examine/use, but if it's unfinished, why would they want to?

Tuesday, August 07, 2007

Threads - Don't Do It!

Here's a warning to anyone who's thinking of using threads - don't bother. Even if you've used them before, I think it serves well to be reminded (me included) that they should be avoided at all costs. Why? Because they make things exponentially more complicated!

Programming is complicated enough, trying to write a block of code that has zero bugs and defects. But what about if the variables you are using could change in mid-line? Or objects that you thought existed because you checked in the previous line now don't exist in the next line?

My multi-player games use at least two running threads; one is the main game loop, and another is the thread that waits for connections from players. This can cause problems in itself - the main game loop obviously loops through the players collection to send them data (and other stuff), but a player can join the game regardless of what stage the main game loop is at. So problems exist in that the main game loop could send all the players the current (say) ammo levels, but if a player had only just joined, they hadn't even been told that a particular unit exists in order to have a gun to contain the ammo!

Unfortunately, the keyboard input is also a seperate thread (as is the norm with Java), and until I corrected it, I was performing IO operations inside the KeyPressed() method. So the client software code could be halfway through sending the unit's location, when the player decide to press space to shoot, and suddenly a stream of bytes representing the "Shoot" command comes steaming through, completely confusing the server. The synchronised keyword fixed this problem of course.

This is just a few minor examples of threading problems. The irony is, that on the face of it threads seem like a great idea - like lots of little programs all doing their own thing. Unfortunately, it's when they have to interact with each other, which they always have to at some time, that problems start.

Thursday, August 02, 2007

Interesting Enemies

I was watching Gamer TV the other day, killing 5 minutes and keeping up with the latest development in non-Free games department, and I saw a video of the new game BioShock. And I wasn't that impressed. It was only a quick video, and I was only glancing it at, but it gave me an insight into what a lot of games (including my own) lack, and that's "anything new". It's probably been said a million times before, but a lot of the games are just Doom with better graphics. I suddenly realised how boring an FPS can be if you're just wandering around shooting the odd enemy that appears. It's stating the obvious, but they need something new to keep the player wanting to play it.

It's with this in mind that I've though of something new! At least, I hope it is, and in the interests of open source and sharing ideas, it's going to a some kind of "fungus" that grows towards the player. It won't be easy to kill (probably impossible in fact) but the player will be able to shoot bits of it away.

Here's my first version of it. It's rudimentary (just using spheres), and I've still yet to perfect my fungus "ai", but it certainly makes an interesting and different enemy.


Tuesday, July 31, 2007

Got it working

After what literally seems like yonks, I've finally worked out the solution to the problem I described several posts back, namely that the perspective was all wrong in my game Passenger - it was drawing stuff further away over the top of stuff that was closer - like this:-



Needless to say, the problem had an easy solution (once you know what it is) - a missing "updateGeometricState()" on the root node when adding an object. Arrggh!!!

Here's what it looks like now:-



A dramatic improvement I'm sure you'll agree. And now I can finally get on with improving the game rather than messing about with small bugs!

Wednesday, July 25, 2007

Warning - Scary Picture!

I've just added some more hardened enemies to Last Remaining, and some more serious firepower. I don't want the game to become just another FPS, as the story is quite important, but it won't do any harm to have a bit of action in the middle of it!

This necessitated enlarging the levels and also adding a new one (now up to 3). I'm just ensuring there are no serious bugs, and then I'll be uploading it to Sourceforge.

Network Communications

Communication between computers is a nightmare, whether it's a web server or a multi-player FPS. How do you know when a client has finished sending you data? Does it disconnect? Does the stream contain an EOF signal? Does the client tell you how many bytes it's going to send?

I've just been trying to write a simple web proxy server, and this is just one of the questions that is proving hard to answer. Some websites (like Google) don't send a content-length (and I don't think it even disconnects once it's finished sending the data). So even if you want to write a simple proxy server that (on the face of it) just passes the bytes between computers, you have to write a piece of software that almost amounts to pretty much a full web server and partial web browser (except without the rendering features).

However, it's more compicated than that because you have to handle the communication two ways for each "connection". So you get the added complication of slow clients (client that connect to a server, and then decide to wait a few milliseconds before actually sending a request). Then there's flushing - when to flush and when to not.

Even though my Proxy now seems to be working for most websites, for some reason it can't read Slashdot (I get a blank response) and Googlemail says it's received a bad request. Gawd knows why.

Tuesday, July 24, 2007

Programming in Java

One of the great things about programming in Java is that it runs straight off in Linux and Windows without even the need to recompile. I've never had any of the problems that I've heard described elsewhere, but maybe I haven't covered the same kind of areas. However, I've written platform games, 3D shooters, desktop applications, database connections, and I think the only time when I've had to include a bit of code that says "if (linux) { do this } else { ... }" etc..., and that was because of slightly difference font sizes, which is fair enough (and probably for patent reasons).

This does sometimes lead you to a false sense of security though. I've been caught out several times by case-sensitivity. A program will work fine on Windows, but then I run it on Linux and it can't find the file "xyz.3ds" because the filename is actually called "Xyz.3ds". Still, a bit of testing should sort that out, and we all do that, don't we?

Friday, July 20, 2007

Ease of Use

One of the major drawbacks of there being so many quality open source games is that it's too easy to dismiss games that don't provide instant and accessible fun.

I'm just as guilty as anyone of this; if I download a game and there's so much as a whiff of having to compile or make anything then it's goodbye from me and onto the next game. Having a young son, I have very little time to play games, so anything that looks like it's going to cost me more time than it should gets discarded.

It's having this in mind that has caused me many a headache in trying to make Nuclear Graveyard instant and accessible. After I'd first completed it up to version 1.0, it had about 12 keys, like "shoot", "wait", "autofire", "guard" etc... A few comments from prospective players had informed me that this had understandably put them off, so I changed it to a menu system.

Unfortunately, I still don't think this has placated them. When you first run the game, it looks like an FPS, so I imagine a lot of players wonder why they can't run around and shoot stuff. (This is because of things like Action Points). I've tried putting big warning signs on the screen saying things like "Out of action points!", and other things to give people an idea of how it works. I just fear that in this day and age, they'll have gone onto another game before they get the idea. Maybe originality doesn't pay!

Thursday, July 19, 2007

Shooting


Now that I've implemented shooting in Last Remaining, getting a good "shooting" feeling in my FPS is proving hard. My first version of shooting was just to move a cylinder away from the player. It generally works, the player can see that they are shooting, and thanks to collision detection, the enemy knows when they have been hit. However, it feels like the player is using a pea-shooter. There's no umph behind it. This may be for several reasons:-

* No sound effect
* No muzzle flash when the bullet comes out
* No sparks where the bullet hits the target
* No camera shake when the player shoots

I think all of these add up to make a good shooting effect, and make the difference between a pop-gun and a BGF9000. I just need to work out the best way to implement them now.

I notice that some shooter don't actually draw the specific bullets. They have all of the above though. Maybe this might be the way to go - it will certainly save on processor time by not having to draw them all.

Tuesday, July 17, 2007

A Mention on Freegamer

I've managed to garner more than my fair share of paragraphs on the excellent Freegamer blog! Thanks Charles. Knowing people are taking an interest in my games, and maybe even gleaning a small amount of fame, is what keeps me programming.


Here's another screenshot from Last Remaining:-



I like the shadows in this one.

Passenger Perspectives

I've started changing the 3D engine I use for Passenger from JOGL to JMonkeyEngine. Unfortunately, I seem to be having trouble with my perspective:-

It seems to be drawing the closest objects first (and even the closest parts of the cloest objects first), which are getting over-drawn by objects that are further away. Still, it all moves at a good speed, and as soon I sort this out it should make the game a lot better. Maybe I could use this new feature for a psychadelic 3D puzzle game?

Monday, July 16, 2007

"Last Remaining" - Now on Sourceforge even more!

Last Remaining has finally been uploaded to Sourceforge - link here. It hasn't made it to the number one position yet, but surely it can be only a matter of time before enough people download this rollercoaster ride of action suspence and adventure! I've added the source code, and another nice screenshot.

Saturday, July 14, 2007

"Last Remaining" - Now on Sourceforge!

..though I haven't had time to actually upload anything yet. It will probably be Monday.

Friday, July 13, 2007

"Last Remaining" Update

I've just mastered two other features of JMonkeyEngine - fog and stars! Actually, after thinking about it, the two are pretty much exclusive, as if there's fog you shouldn't be able to see any stars. However, as my previous post alluded to, realism isn't the name of the game.


Unfortnately, the non-disclosure agreement I have with myself prevents me from telling you what this particular map is, whether it is populated by unfriendly aliens, or where it fits into the story. It may or may not be set in space, and may or may not be some kind of spaceship, and the aliens may or may not want to kill you.

What I can tell you is that I've added some rudimentary sound effects (always good for atmos) and even some fitting music. No word back from Sourceforge yet though...

Wednesday, July 11, 2007

Scenery

IMHO, one things that makes a good 3D game is scenery. Call it blindingly obvious, but any 3D game without scenery might as well be Wolfenstein (or even 3D Monster Maze, and that's sooo 1980's). To this end, I've just added some signs to the map that the player starts on, to make it more homely and, err - I can't think of the word. Realistic? Maybe, but it's set in the future anyway, so realism isn't exactly top of the agenda. More natural? Easier to navigate around? I dunno, I give up.

I've almost done the first "episode" of this game that I've christened Last Remaining, and as soon as Sourceforge get off their *rses and accept my project, the sooner the proles can play it and hopefully give me some feedback. It's far from complete (what comes before alpha?) but has the makings of a could-be-good game.

Monday, July 09, 2007

"Last Remaining" - We have Lift Off!


I've finally had some great ideas for the story for my new game Last Remaining. I won't go into too much details here, as "the story" is going to be this games biggest selling point, and revealing it now would strip anyone of the main reason to play the game. However, basically the player plays the part of a space-wreckage-investigator (I'm sure there is a more succint way of describing that, but there you are).

I had a bit of a quandy as to how best to show the speech by the NPC's - do I show speech bubbles, showing writing along the bottom of the screen, or destroy my whole reputation and have a go at some voice acting? In the end I decided to go for the pseudo-speech bubble option, as it was easiest.

Another minor request for advice - I had amazing trouble trying to get the OrientedBoundingBox to work in JMonkeyEngine. In fact I still can't get it to work, so I decided to use Rays instead to check for LOS. Does the OrientedBoundingBox actually work in JME?

Anyway, now I've got all the major functions for a 3D RPG, like LOS, speech bubbles, collision detection and map files, I'm all set. Downloads are here, but are probably a bit out of date. I've just registered the project on Sourceforge, so I'm just waiting for them to accept it (or otherwise...)

3D Model Drought


The biggest problem I have with writing 3D games is finding free decent models. And yesterday I thought I'd hit gold with Google's 3D warehouse - a whole website of free 3D models with the usual excellent Google search facilities! I was set for life!

Unfortunately, the commercial reality has set in. The models are all in Sketchup format, and in order to export to any other format (with the exception of Google Earth) you need to buy the Pro Edition of Sketchup. Grrr!

Unless I can find a free convertor somewhere on teh interweb?

Friday, June 29, 2007

I've started a new game!

My latest project, which as usual has started out in a flurry of exceitement but will soon fizzle out as the real world of programming problems set in, is a 3D adventure in the style of Deus Ex. Here's a screenshot of the setup. There's no game, just an environment to walk around in:



So far I've got sliding doors, some stairs, and a man with a pidgeon chest, so there's plenty of stuff to do, like a story and pretty much everything.


BTW, this is written in Java using the excellent jMonkeyEngine.

Monday, June 25, 2007

Feedback

I don't know if I should feel slightly annoyed with myself or with the open-source community. I uploaded a new version of Nuclear Graveyard on May 2nd. Since that date, the number of players slowly dwindled, and I was wondering why. I thought people had maybe got bored of it. However, it was still being downloaded 2-3 times a day.

Then, just today (June 25th) I received an email from a kind soul who has informed me that the download from Sourceforge is corrupt! Aaaarrrgghhhhh!! I know it was my fault for uploading a corrupt file and then not testing it, but you would have thought that one of the 100+ people that have downloaded it might have just sent me a quick email to let me know!

Friday, June 22, 2007

Programming 3D Games is a PITA!

I'm going to log here all the small problems I have with 3D programming, hopefully so that I don't succumb to them again. Most of them are probably applicable to programming 3D in any language or platform.


Q. Why can't I see my 3D bullets, which are cylinders? They worked when they were spheres!?
A. It's because you are shooting them from the camera's location. If they are not "closed" cylinders, and you are culling the inside of the cylinder, then they are effectively invisible since the camera is not looking at the outer surface, which is the only visible part.


Q. Why can't I see anything?
A. It could be any of a million things. Is the camera at it's correct location/direction? Is the camera inside the 3D object that it is trying to look at?

Wednesday, June 20, 2007

Manhunt 2 banned in the U.K

So Manhunt 2 has been banned in the U.K. God knows I hate censorship! It's like religeon - why do some people think that they have the right to determine what other adults can and cannot see? What makes them so special?

And in a deliberate turn of irony, I'm going to try and get it, just to find out what the fuss is about. If it's been banned, it must be good.

Friday, June 08, 2007

Online Gaming Organiser

Updates to my games have been a bit slow recently, and I think I can now announce why. I've just set up a brand new website called "NewGame!", and it's designed to be an on-line gaming session organiser.

One of the problems with a lot of on-line games (especially the not-so-famous ones) is that the worlds are often very sparse of players. I run a couple of on-line games that get several players a day, but unfortunately it's quite rare that they will join at the same time, making the players experience a lot less fun.

This website is designed to help this siutation by making it easy to organise a gaming session for a particular game, and then automatically email everyone else who has highlighted that game as being one they play. The date and time are chosen, and voila! Everyone plays at the same time and the gaming world is populated by more than bots. It does other helpful stuff like take into account players' timezones, and links to the games home pages, and also highlights which games are free.

By the way, the address is http://onlinegameplanner.no-ip.org. It's just started, so the membership is pretty sparse. However, I'm hoping people will just add their names on the off-chance that someone will organise a session for their favourite game, and slowly the numbers will increase.

Wednesday, June 06, 2007

Microsoft Developers Don't Even Understand the Licence Agreements

Buried in this story of typical Microsoft bullying (briefly, a programmer won an award from Microsoft for developing an add-on for Visual Studio, and was then threatened with legal action for developing the very same add-on) was this email from the Microserf:-

From: Jason Weber [Micro$oft]
To: Jamie Cansdale [bedroom programmer]
Date: Dec 9, 2005 4:37 AM
Subject: RE: Follow-up Information

Since I'm not a lawyer I shouldn't comment on the license. However if
you read the Express SKU EULA you'll see verbiage around reverse
engineering, and if you read the VS SDK license (the license that covers
all native API's that you're accessing when you QueryService from your
add-in) you'll see additional terms that are relevant to your hack.
Sorry that I can't be more specific, but I'm just a developer ;-)

Later - jason


So Jason, the Microsoft clone with an army of lawyers at his disposal, doesn't understand the licence agreements, but he's expecting the poor bedroom programmer to understand them? Programming is hard enough without threatening lawyers letters from the chief innovation-destroyer!

Tuesday, June 05, 2007

jMonkeyEngine

I may well have been the last person in the world to discover this little gem, but discover it I have. It's a 3D Engine that sits on top of LWJGL or JOGL to make a lot of OpenGL (especially the more complex bits, like lighting) much easier. I'm currently changing Passenger to use it. That should make it look a lot more realistic, and I should hopefully be able to add more interesting scenery, like neon lights.

Wednesday, May 30, 2007

Unreliable XBox 360's

It looks like Micro$oft is doing an Apple, and completely denying that there's a serious problem of XBox 360's lasting approx 12-18 months before crashing and burning. No doubt it will only be when the mainstream media get hold of it that they will acknowledge that there's a problem. However, at the moment there's profit to be made from charging people ~£80 to repair something that shouldn't have broken in the first place.

Will I ever need to power-down my PC that quickly?

Who's idea was it to incorporate a power-off button onto keyboards? What is the point? And especially, why put it next to another commonly used key? On my Genuisnet.com keyboard it is just below the Delete key. I've lost count of how many times I've knocked it, and all my applications have suddenly closed right in the middle of programming. Aaarggh!! If I want to turn my PC off, I'll press the power button that sits on the case approximately two feet away! Why do I need it on the keyboard?!?!

Tuesday, May 22, 2007

Latest Releases

I thought I might as well mention the new releases of my games, in case anyone's interested!

Nuclear Graveyard - The biggest complaint about this game was all the keys. I've now added a new menu system, so all the functions can be accessed from this. You can now also click on a units stats to select them, and click on the map in the top-right corner to change the view mode.

Passenger - I changed this so that it now uses floats for the angle, rather than integers. This has led to much smoother turning. I still need some decent animated 3D models though!

DangerMan - I changed the targetting on this so that the mouse pointer is a crosshairs (just like Abuse). I think this improves the playability. I also changed it so that the sprite coords are floats rather than integers. I thought this might slow things down, but it seems okay. I need to work on the maps now.

HoloRacer - This now compiles some of the OpenGL shapes for improved performance, and I also widened the track. I also got it to remember which level the player reaches, so if they restart the game, then can jump straight to the latest level. I've managed to get to Level 5 - beat that!

Thursday, May 10, 2007

When to Check Collision Detection?

This post is not going to cover the actual detection of collisions between sprites; I think there's already more than enough of that on the net for a lifetimes reading. I'm talking about "when" we check for collisions...

I previously used to process all my game objects sequentially, and check for collisions against every other object. However, the problem with this is that the program will be checking for collisions between object A and object B, and then checking object B for collisions with object A. This is time wasted, as presumably if object A hasn't hit object B, then object B hasn't hit object A. (This assumes that all object movement has been carried out already)

What I now do is loop through each object, and only check for collisions against all the objects placed after the current object in the game's "list of objects". So object A is checked against object B and C, and object B now checks only against object C, whereas previously it would also have checked against object A as well.

So if my game had 100 objects, it was checking for collisions 9,900 times in each game loop (100 objects x 99 other objects). However it now only checks 4,950 (I think) times!

Watch Out for Eclipse and Subversion

If you're using Eclipse and Subversion at the same time, beware. When compiling, Eclipse copies the src directory over the bin directory. Presumably this is perfectly okay for most people. However, if you're using Subversion, this means that it will also copy the .svn directory that is inside src. The upshot is that Subversion now thinks that your bin directory is your src directory: it will think all the source files are missing, and try and update them.

And don't make the mistake that I did, before I discovered the above problem: I svn-deleted the source files from the bin directory, assuming they shouldn't be there (which technically they shouldn't). However, when I then update my src directory, it deleted all the source files from there as well! It did this because when I deleted them from the bin directory, Subversion thought it was the src directory!

I'm now trying Subclipse...

Friday, March 23, 2007

Self-Indulgence

Sometimes, in a very self-indulgent way, I like to search for my games on the internet and see if anyone else has mentioned them. I think this is one of the main reasons why I write games - for fame! (Not fortune, as they are fully open source, though donations are welcome). Sometimes I strike gold, and sometimes I don't. 90% of the links that are to my game are just agregators for Sourceforge, but here are a few mentions I've got:-

Nuclear Graveyard:
A mini review - though someone has replied complaining that it's multiplayer only, which it definitely isn't. (The review even mentions the AI!)

Holoracer
"Holoracer 3 announced!". What? They make me sound like a proper software company that does press releases! I don't remember "announcing it". I unleash it! (Sometimes via a magazine, it seems)

Friday, March 16, 2007

The Quality of Open-Source Software...

..is too high, especially where graphics in games are concerned. My own projects pale in comparison, and it's got me wondering whether it's worth starting a new project unless you've got an excellent graphic designer on board.

Unfortunately, graphics to play a large part in the popularity of a game, whether it's getting people to play it, or getting them to enjoy it. Back in the day, when I wrote my games for the Spectrum, it wasn't a problem as all games looked awful. But now it's different, and with games like Tremulous setting the standard, what hope have we got?

Sunday, February 11, 2007

Apache2 and PHP5

[For ref - to be updated]

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
AddHandler php5-script php
AddType text/html php
#
# Cause the PHP interpreter handle files with a .php extension.
#

SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 9524288


AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

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) {
super();
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.

Wednesday, December 06, 2006

Downtime

One of the hazards of hosting games on a server that also doubles as the family computer was demonstrated today when my wife accidentally knocked the chair into the power switch! I was at work, and only noticed when I got home. Oh well. I don't think anyone was affected.

Tuesday, December 05, 2006

A Mention!

In my quest for publicity (to get people to play the game) I have managed to garner a mention for Nuclear Graveyard on the excellent Freegamer blog. Okay, it's only small, but it might snowball?

Wednesday, November 08, 2006

Publicity

I'm now facing the greatest challenge of all game development - getting people to play it. For some reason, people will go out and pay for games in their thousands, but then a game which is just as good yet completely free (not my game, BTW) will remain obscure. Where's the logic in that? Where are the magazines dedicated to free games that people can play straight away?

My current pet project, Nuclear Graveyard, is proving obscure and hidden to the public. I've created the obligatory website, some forums, this blog, and even posted some news items on Sourceforge in the hope of bumbing up its rank. However, on average only one person is connecting per day (even though it's being downloaded about 3 times a day on average(?)). What's a programmer to do? Pay people to play it??

PS - If you do play it, please please email me and let me know - even if it's to tell me why it's the worst game you've ever played (since my last one).

Saturday, October 21, 2006

Latency

What a pain this is! For my FPS, I originally planned to have all control processed on the server to keep things simple: if the user pressed a key on the client, that would get sent to the server, the server would process it and send back a command to the client to say "the unit you control has moved forwards".

In practise, even though the delay was a fraction of a second, it seemed like a lifetime, and movement was incredibly sluggish, as most people who've tried to write an FPS can probably attest to. Instead now, I've had to give the client details of all the map and all the other objects it could collide into, and get it to do the movement processing itself.

Now, when the player presses a key, the client checks for collisions before sending a command back to the server saying "this object has now moved forwards - tell all the other clients please". It works a lot better and movement is now brisk, but it's a lot more complex and involved since I have to do collision detection on the server AND the clients, and make sure they are all in sync.

Tuesday, October 17, 2006

N-Grave Up and Running

Nuclear Graveyard (or N-Grave as I like to call it) has now been up and running for several days, after my project was accepted by SOurceforge (actually, I'd be curious to know if there were any projects they didn't accept. But I digress). I've got two servers up and running and waiting. All I need now are some players! And to get those, I need publicity.

So far, I've created the obligatory web page, and even set up some forums. I guess I just need Google to trawl through it and add it to their directory?

Friday, October 13, 2006

Threads!

Every time I use threads I wish I hadn't! IMHO they exponentially multiply any problems you might have in code and often far outweight their benefit.

My latest bugbear (which I've come across before but not learnt my lesson) is "accidentally" using different threads to read incoming bytes from a scoket. Obviously this is a big mistake as the ordering of bytes is critical, so if you've got two threads reading the bytes, god-knows which thread is going to read which btye.

My first mistake was to create a new form which read some bytes; I temporarily forgot that forms run in their own thread, so my comms broke down until I spotted this.

My next mistake was to forget how quick computers are. Instead of the form using its own thread, the main thread waits until the form disappears and then reads the bytes after that. However, a split second before that my main game loop is started, which also reads incoming bytes. In the 100th of a second between the form being closed and the main thread realising that the form has been closed, my main game loop starts reading in bytes itself and causing chaos.

I know I should have a single sycnhronized method to do this, but there's loads of code to change. Suggestions welcome.

Tuesday, October 10, 2006

Nuclear Graveyard

After playing the excellent game Tremulous, I was inspired to fork Laser Squad 3D and turn it into something better. I'd been thinking of turning it into a fully on-line game for ages, but I couldn't quite see how to do it. After all, it's not your basic Quake variant; you control whole squads of people.

Anyway, Nuclear Graveyward is the result. If I get asked, I'll post about how I came up with the name (but it's not that interesting). I haven't actually released this game yet as I'm still tweaking it. (The problem with fully on-line games is that you can't afford to have any bugs in there without disillusioning loads of people in one go). If anyone fancies being a playtester or writing some instructions for it, just email me and I'll send you the game.

If you've played Laser Squad 3D you'll know the basics of how the game works. However, now it's fully on-line, it's slightly different. Players can join at any time and select any unit on their side (assuming it's not already being controlled by someone). So that means you can have several people playing against several people; you can have a squad of different human players playing against the computer. Strategy and communication between players is the key.