I'd like to build an iPhone game for the Game Center and am currently researching the server part of it all. I learn best by example and I'm having a hard time finding any examples of simple game servers that demonstrate...
I'd like to build the game server using Ruby on Rails, though I'll settle for any examples using any framework just to understand how these concepts work. Does anyone know of any books or online resources that has covered this or shows some example code on how to build a game server?
I would have to think that most multiplayer games on the iPhone require a gamer server, yet I can't seem to find any resources that discuss how to build one. Ever resource I find that discusses building multiplayer games (including Apple's docs) says the same thing, "Developing a game server is outside the scope of this book, but we’ll focus on the client side code necessary to connect to such a server."
Thanks so much in advance for your help!
EDIT: A few more details about what I'm trying to accomplish...
I'm trying to develop a two player (possibly more) game that where the users compete to solve a puzzle faster than the other player. Match making will be handled by the Game Center, but I'll need a game server that will start/manage the games and store the results in a DB. The overall process will be something like...
OK, after reading your edit, Node.js should do the job quite well I think.
Regarding your points:
I don't know how exactly the pairing works(guess you get a pair of keys or so to validate the requests) but it should be hard to implement, regardless of the programming language.
Easy: Setup a server, handle connections, keep a list of running games, for each game keep track of the state(players, time etc.), that should be at maximum(well depending on the message procotol you use..) 150-200 lines
Just send some kind of ready event to each of the players in a given game when you deem that game to be ready(like everyone touched the 'I'm ready' button or so)
OK, some tips here:
Track the remaining/passed time on the server and send it to the players, timers get off pretty quickly(I had 4-5 secs off in just about 3 minutes)
To prevent cheating, validate the moves on the server, that should be fairly easy in case of a puzzle game. You could also check the times between each move everything below 50ms should be suspicious, but that mainly depends on the difficulty of the puzzles.
By checking the moves on the server this is pretty easy too, you don't have to rely on a client sending you a "Look I'm done" message.
Again easy, just send out the events with the accompanying data and log the points into the db.
The most important point is obviously the prevention of cheating, in case of a puzzle game where the solution can be easily solved by a computer, it's impossible to prevent it completely. Although, with the tips above you can make it harder.
But keep in mind, you can't stop people from cheating on the high-scores when the game is simple, building more and more protection into the game just doesn't make sense. Focus on the game-play, make it interesting and simple for humans but complex and unpredictable for computers.
In case of the DB, uh... I suppose you could go with MongoDB for that, but I haven't played around with that under Node yet.
Oh, and if you want a impression what you can do with Node.js here's the game that I've built:
http://github.com/BonsaiDen/NodeGame-Shooter
All the logic runs on the server, the clients just draw the stuff they know about, I had a playable prototype up and running in two evenings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With