Chapter 17. Multiplayer Games

In earlier sections of this book, we discussed the difficulty of creating true artificial intelligence. While we dabbled in some light artificial intelligence earlier, the really complex algorithms used in the latest games are well beyond the scope of this book. You've probably realized by now how complicated it would be to really mimic a human player. It's so complicated that in many cases, depending on the game, it's downright impossible.

Chances are you've played an RTS (Real-Time Strategy) game where the computer player leaves his base too unguarded, or a football simulation game where there's one defensive play that stops the offense every single time no matter what offensive play was called. This is one reason why multiplayer gaming is such an enjoyable experience—there really is nothing like playing against a real, live human opponent. Throw in the fun of trash talking and stat crunching and the general pride that typically results from winning these games, and multiplayer gaming can really become addicting.

In this section, we'll discuss different means of implementing multiplayer functionality in your games. First, we'll look at adding split-screen functionality to your game, and then we'll walk through building a new game using the XNA Framework networking API.

Split-Screen Functionality

One way to add multiplayer functionality to your games is to implement a split screen on a single monitor (for the PC) or television set (for the Xbox 360). ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.