A Java-Based High-Score Server
A CGI Approach to Tracking High Scores
By Neil Bartlett
What compels you to play yet another turn of a computer game? Hands up everyone who, like me, replied, "to try and beat the high score." Aren't we a competitive bunch! Sure, playing the game is fun, but it's the quest to beat that darn high score that keeps you coming back for more. The game high-score recording mechanism is like a digital narcotic ý it keeps you hooked.
This article shows how to design a high-score recorder that can be used for any Web-based game. I'll first discuss the design, then I'll look at security issues, and finally I'll suggest improvements that will make it really sing.
The code samples are all written in Java since it is fast becoming the language of the Web, but most of the concepts are Java independent. The article assumes knowledge of Java programming, specifically, programming I/O, sockets, and ports.
Basic Score Recording
Writing a high-score recorder sounds remarkably easyýjust get the score, test if it is the high score, and shove it in a file somewhere, right? Well, the principles are simple, but the execution presents a few challenges.
Imagine a game, say, a zap-the-baddies game, in which players employ various weapons of mass destruction to blast alien bad guys in exchange for points (the less violently inclined can imagine a points-driven game). At the end of the game, we want to store our accumulated points as a score in a ranked high-score table.