Tuesday, February 12, 2008

2pTD - Development Part 1

Here's my post to attempt to describe the technology behind my 2pTD game.
Basics:

  • One developer (Grant), MTASC + swfmill, 2 months to develop

  • Flash-based client communicates with servers using XML via XMLSocket connection.

  • dmtdsrv: Custom Python/C server utilizing libevent (base game engine)

  • 1 or more dmtdsrv servers acting as lobbies (where games start, high scores, current games)

  • 1 or more dmtdsrv servers acting as game session servers (where the actual game is simulated)

  • lighttpd web server

  • memcached which holds game and misc. state info


Details:
Once the flash client is loaded, they connect to the lobby which shows current games. When they select start single or multiple, players are assigned to a session ID, which is used to determine which session server they will be connecting to. Players are internally mapped to a session as well during the transition from the lobby to the game session -- this also prevents players from joining sessions which they weren't meant to be in. All communication is done via (not so compact) XML messages.

The client is intentionally as dumb as possible to avoid cheating and to allow the server to be the authority. All the tower specifics such as amount of damage and ranges are all determine server-side. This has the side-effect of making replays and real-time spectating of games possible without making massive changes to the flash client code. The flash client code was actually written completely in ActionScript using swfmill and MTASC to build.

Graphical resources were built using a combination of custom vector editors/animators and various graphics editors. Stay tuned for more info on these tools.

After every tower wave the game session state is sent to the memcache so it can be displayed in the lobby. Each session server is uniquely named and can handle many sessions. The system is designed to be able to handle high loads by starting many session daemons across many distributed servers -- although right now it's just 1 lobby and 1 game session.

Try playing 2pTD!

Part 2 will cover the unit pathing system, part 3 will cover the dead reckoning system.