Friday, 1 February 2008

An Adventure in Webservices

It's not very often I get motivated to do some development in my spare time, but when I do I usually surprise myself with how easily my ideas come together. The last couple of weeks I've had a real boner over Webservices (yeah, yeah, so I'm late to the party), mainly because my current project at work uses them extensively.

I wanted to put a webservice to use in a more creative way. I've had this idea of a multiplayer top-down tile-based adventure style game in the form of early Ultimas. It's an idea that's been kicking around for a while but I've had little or no reason (or time) to go ahead and try to make it.

Until the other day, that is. May I present to you Webservice Adventure:



Doesn't look like much does it?

The .NET solution consists of two projects - a webservice and a client web app. Player information is stored in an Access (haha) database. The webservice has a few very simple webmethods that pull information from the database. For instance, to draw the map, the client app calls GetUpdate, which returns a 9x9 int array of tiles as well as information about your character, characters on the same map as you and any lines of chat text that are relevant.

When the Up button on the client is clicked, the client fires off a call to the webmethod Move(), passing along an X and a Y direction. The webservice updates the player's location in the database.

Simple stuff. Not blisteringly fast, of course: The client only updates once a second with an AJAX timer. Clicking frantically on the directional arrows obviously causes webservice requests to get lost. But nothing breaks as yet. I've even tested it online and it's only a little slower than local play.

If speed is the downside to weservices, then the plus sides have to be: not neededing a permanantly running process (windows app/service) to run the game updates; no networking requirements (open ports etc.); and no client-side requirements other than javascript.

One of my favourite features (probably because I only added it last night!) is zoning. Each area map is a separate text file, and exits are stored in the database linking different maps together. The next picture shows me on my own after entering the building in the first screenshot:



I'm not sure where to go from here. Got a few things to add such as uploading an avatar for a new character; but after that I'm not so sure what I'm going to add to it. As it stands, it's a functional multiplayer chat game I guess. Any suggestions?

No comments: