Wednesday, May 18, 2011

Battle for Venga Islands

After Bad Golf, I took a month or so off of game programming, but then I got a bit of an inspiration.

I read about Spyn Doctor's high score sharing component. This is a bit of code that replicates the idea of a central, shared scoreboard for a game. So, pretend you have a Space Invaders game. It's a single player game, and you play to see how high a score you can get. Wouldn't it be fun to see other people's scores? This component allows for that.

What it does it open network connections while you're playing the game, and it looks for other people playing your game that that exact same time. When it finds someone, it takes your high score table, and their high score table, and merges the two together. So now your high score table has aggregated scores from two people. This process repeats, always looking for other players, and keeps sharing and sharing and sharing as much as possible. And when you share, not only do you share your own high scores, but all the high scores in your list (that might have come from somewhere else). So scores propagate around the system. It's very unlikely that everyone's high score tables will be in sync, but you get the idea.

Now, the glorious thing about the code is that it's generalized. It doesn't HAVE to be used to share high scores. It could be used to share any kind of data. He just provides sample implementation of sharing high scores.

So I got to thinking. What kind of game could I make that shared some other kind of data?

The immediate issue is synchronization, or lack thereof. You have to make a game where it's ok for things to be out of sync as you share data with someone else.

My first thought was something like this: What if you have some huge amount of "work" that needed to be done. Each player begins playing, and requests pieces of work that haven't been done yet. When they finish a piece of work, they mark it as complete, and repeat the process. The data that is shared, of course, are the pieces of work that I've completed.

The idea is very much like the SETI@Home system. It doesn't matter if multiple people work on the same piece of work, as long as SOMEONE does it.

So, what kind of "work" could I provide to players that would be fun? My first thought was a giant maze. Like, a 2D maze that you'd make on graph paper. Each cell of the maze is a room (like, in Zelda). Players would play some little game in the room (like, killing all the monsters), in order to mark it as complete. When a room is marked as complete, that data is shared with all other players. If multiple players mark a room as complete, it's ok. Nothing breaks.

As more and more players fill in the maze, everyone can build off each others work, and finally complete the entire world. What then? Who knows.

Early Maze Game

That idea morphed a bit into having a country, with multiple regions in it. Players would be assigned to one of two teams, and try to capture regions, again by playing a little mini-game in each region. Region ownership data, then, would be the data that is passed around to peers.

I started out with an SVG map of the United States, divided up by counties. Dealing with SVG proved beyond me. But I found some fabulous information about making polygonal maps, including a tool to create your own and export it as XML. Soon enough, I had my own big map going.

Early Map

The game started to take shape. Players are assigned to either the Red or Blue team. They look at the map, and who owns what regions. They choose a region to try to capture, and play a little twin-stick shooter mini game to try to capture the region. If they capture the region, then that goes into their "high score list", and marked as data to be traded with other peers.

During development, Magicka came out. So I tried my hand at special effect programming to make some cool spell effects, and that did a lot to set the tone of the game.

Early Gameplay

The key to the entire system is that the time that each region is captured is stored in a synchronized timestamp. When region data is compared, that timestamp is used to determine who owns the region.

An example is in order:

Player R is on the Red team.
Player B is on the Blue team.
Player C is on the Red team.

Player R captures region #123 on his own local Xbox.
Soon after, Player B captures the same region on her local Xbox.
Player C doesn't do anything.

At this point in time, all three maps are out of sync. Region 123 is claimed by red for R, blue for B, and unclaimed for C. (Do you see why?)

As the games detect each other on the network, these differences are worked out. If R and B connect, then B's map won't change, but R's map will show the region now owned by the Blue team (because B captured it later). When either R or B connect to C, C will be updated to show the region owned by Blue.

When taken all together, this provides a shifting, changing, evolving battlefield. IT DOESN'T MATTER that everyone's map may be wildly out of sync. What only matters is that each individual player will see their own map changing.  Until I'm proven wrong, I think this is pretty clever, and I don't think anything like it has been done on the XBLIG platform.

After some time, the map and gameplay were all pretty much set. I added a Difficulty rating to each region that is dependent on the surrounding regions. That is, a region that is surrounded by regions owned by your team should be much easier to capture than regions that are surrounded by (or owned by) your opponent. This should (I hope) have the effect of creating natural "battle fronts".  It should be pretty impossible to capture a region that is "behind enemy lines", but much easier to capture regions on the border between yours and theirs.

I also added a "Regions Captured" high score list, that is shared in the traditional way.  This is a globally shared list that shows the top 100 conquerors. This should provide some motivation for players to capture more and more regions for their team.

I'm a PS3 and PC gamer. Multiplayer gaming has always been free for me. To do network gaming (even data sharing in the background!) for the Xbox, however, requires a paid membership. This meant that only a subset of actual players would get the full experience of taking part in the dynamic world. Everyone else will just have a blank map that will never get updated. Pretty boring. I added a "Quickplay" option, where they can just play the fighting part of the game (and choose their own difficulty), but I admit I'm not sure that's worth the price of the game.  Luckily everyone gets to try it before they buy it.

After a few months of development, I got things all up and tested. I enlisted my friend Eryn to do a pretty cool loading screen, and was put in touch with a student musician to do custom music for me.

I threw together a little video and some screenshots, and submitted for review!

And some screenshots...

The whole thing is a pretty big experiment, but I've gone over it every which way in my head and don't see any reason why it shouldn't work.  It's halfway through peer review, and should come out very soon, so nothing to do now but wait and see!  I plan on leaving my Xbox on, at least for a while, to see how the world evolves.  Should be pretty exciting!

No comments:

Post a Comment