tags:

views:

27

answers:

2

I made a simple pong game from a tutorial (icode blog)and would like to play againt another player over my wifi network. How do I add that feature to the game?

+1  A: 

There are two ways to go about this. The first, and easiest, is to use Game Kit's peer-to-peer networking to connect two devices. As of iPhone OS 3.1, Game Kit works over WiFi as well as Bluetooth. I show how to do this in the Networking session of my iPhone class on iTunes U. This sample application I wrote for the class demonstrates the use of Game Kit to communicate between two applications.

While Game Kit is the simplest way to go, it only works for communication between two devices running iPhone OS 3.1+. For more generic WiFi networking, I'd recommend looking to Bonjour discovery. Again, I show an example for that in the above-linked class, and use code assembled by Bill Dudney in his "Bonjour Network Server for iPhone" article. The neat thing about this approach is that you can also communicate with desktop applications, like with the Mac client that I created for the class.

Brad Larson