Peer-to-Peer FPS


The code is located here. I used Microsoft Visual Studio 2008 to create it, and it uses Ogre 1.6 and raknet, which you'll have to provide yourself if you wish to compile it. You'll also need the media folder included below.

The binary is located here. It should run on its own with no problem. Your player name can be changed by editing Player.cfg. WASD to move, space to jump, left mouse button to fire, escape to quit. When it first starts up, it'll ask you to provide some graphics options.


Overview

The main purpose of this project was to learn how to use raknet and ogre together. It also demonstrates how games can find other servers on the network without having to query a main server for the listing. When a game starts, it sends out a multicast ping on a certain port, and then tries to connect to every pong it receives. This is done in the background so there is no need for menus or creating/joining a server, the game takes care of that. Since it is peer-to-peer, players may come and go as they please as the game is dependent on any one machine.

Since finding a server is just based on pinging, any complex network (like the internet) and any firewalls/NATs/etc will likely result in a failure to connect. Peer-to-peer also introduces cheating as there is no longer a central server verifying data, clients have to trust each other to be honest. But for simple LAN games this method works pretty well (and I think its cool that people just 'magically' join your game).

Since the main focus of this was networking, the collision detection is a very simple system based on shooting a ray downward to find the ground, and in the direction you're moving to see if you hit anything that way. There is no physics system. There is also an issue where sometimes firing your laser isn't reciprocated on other machines, but I'm not sure if that's a bug or just due to my second laptop being very slow.


Pictures/Movies

Here is a video demonstrating another person joining a game, and jumping around/shooting.