iOS turn-based vs real-time multiplayer connectivity options - ios

I am looking into multiplayer connectivity options for a two player game and wondering what options are available to use. I've read up on a bunch of stuff online but still couldn't figure this out. I've done a tutorial with GKSession from GameKit.h, but I'm confused on whether Game Center and GameKit are the same thing.
What are some connectivity options for both a turn-based and real-time two player game? Are there any benefits for either styles with these connectivity options?
Thank you!

Game Center is the customer-facing name of the services Apple provides. GameKit is the framework that Apple provides for developers to implement Game Center functionality.
Whether or not you make a turn-based or real-time game really depends on the type of game you're making.

Definitely agree with #WendiKidd -- you need to decide what type of game you are making to determine the technology to use. Game Center won't directly solve this for you, it will just provide an API for "extra" that you can hook into.
That being said, turn-based is probably easier to write and has a few more options for implementation. You'll need/want to setup a server in the middle that can act as the central arbiter for the different players. E.g., player one submits a move, which gets sent to your server. Then when player two logs in/plays, the game would check against the server for updates and then affect the game state accordingly.

Related

Xcode Mass Multiplayer (Not What You're Probably Thinking)

Okay so I would like to make a game, I'm trying not to divulge what it is but it requires anyone of a certain level in the game who is currently playing to be able to see each other in a sort of MMO style but not really.
For example:
Suppose I have players Bob, Mary, and Rob. Suppose that Bob is level 4, Mary is level 6 and Rob is also level 4. These would be shown in leaderboards by the way. What I would like is for Bob and Rob and anyone else who is level 4 AND CURRENTLY PLAYING to see each other in a sprite kit seen. I would like Mary to be off with other level 6's.
I have little idea of where to start with this. So my questions are:
Should I even use Xcode or would I be better off using Unity?
Does GameCenter have the capabilities for this or would I need to use Parse or something like that
And also, could you please point me in the right direction as far as the concepts of how this would work?
If you can answer any of this that would be AWESOME!!!!! If not that's cool too! Thanks in advance!
Xcode is an IDE and Unity is a Game-Engime.
If you need to create your own game since the beginning, you should use an IDE. But this is really LONG and sometime difficult. With a Game-Engime, a big part of the game is already programmed (physic, 3D animations...) so you can focus your time for program your game.
Game Center is for share a game or a score. Not played online.
For play online, you should create your own server.
Do you know how to program? Are you good in 2D/3D?
For create an MMO game, you must be logic.
First, you should create a client.
The client is the game
He contain the sounds, the graphics, the scripts...
Second, you should create a server.
The server is connected to all clients.
He contains the databases (Accounts, characters, HP, gold...)
So where started?
When a character move (from the client A), he send his new position to the server. The server send this position to all the client. So the client B know where is the character of the client A and can draw a tileset (in your example, you can draw the tileset only if the boolean sameLevel is true).
Take a look at the sockets:
http://www.linuxhowtos.org/C_C++/socket.htm
http://www.nullterminator.net/winsock.html
https://stackoverflow.com/questions/tagged/sockets%20c%2b%2b
https://stackoverflow.com/questions/tagged/sockets+c
Hint - I have already answer at some similar questions. Even if the programming language are sometime different, I give you the link, the logic is always the same so it can maybe help you:
Creating a Multiplayer game in python
Multiplayer game in Java. Connect client (player) to game that was created by other client
How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game?

How Does Spaceteam Work?

For those not in the know, Spaceteam is a very popular and very fun multiplayer game for iOS.
It allows for real time gameplay among multiple devices on an ad-hoc Wifi network - how does it do this?
Are there published libraries describing how to build protocols on top of ad-hoc networking libraries? Is it iOS specific, or would it be possible to build a variety of applications across different platforms?
Quickly, answer before we hit the asteroid!
Specifically which aspect are you interested in? There's nothing particularly special about mobile devices or ad hoc Wi-Fi networks (except in an ad hoc network, not all devices may be able to communicate with each other, so some mesh networking can help but unnecessarily complicates matters for the normal case).
I'll answer the broader question first, because it's more interesting. In my experience, there are a handful of major considerations:
Server/client or peer-to-peer? By this I mean whether there's a "master" deciding the true state of the world and communicating this to all clients. Avara is the only game I know of that is "peer-to-peer" in this sense (peers sent commands to all other peers; this proved bandwidth-heavy for modem users on 6-player games). I am not aware of games using more sophisticated network topologies to communicate game state (e.g. only sending data to one client on each LAN).
What do you do about latency? Avara is the only game I know of which lags everyone locally by the "latency tolerance" in order to get a consistent state of the world, which was terrible if someone was on a modem (turning off compression helped a lot). There are various ways to do "latency compensation" (e.g. in Half-Life/CS), some of which could also work on peer-to-peer games.
Time sync? For client-server games, you at least need to worry about a changing RTT. For peer-to-peer games, I think you also want to agree on timing that minimizes the effective maximum latency.
What if clients disagree about the state of the world? Avara just lets peers decide on their own state of the world (and displays "reality fragmentation detected" if it senses a mismatch, which might happen due to dropped packets or a too-low "latency tolerance").
What if a player leaves? For a P2P game, you might have to agree on a consistent game state (e.g. if the player was disconnected after sending commands to a subset of other peers). For a client-server game, you might have to elect a new master.
And now, after watching the Spaceteam trailer:
I have no idea how it works, since I haven't reverse-engineered the protocol. However, it's pretty simple to make something that works well enough:
Use some sort of P2P discovery to find players (e.g. Bonjour; there should be plenty of docs and samples out there).
Communicate with peers. I've done this with GameKit circa iOS 3/4 (I'm not sure if it still works over Wi-Fi).
Elect a master. This can be as simple as whoever presses "ready" last attempts to be the master. In some edge cases you might have to handle failure.
Let the master decide everything. Spaceteam is not latency-sensitive; Wi-Fi latency tends to be at most a handful of milliseconds, and nobody's really going to notice if one device is slower by 100 ms (as long as the UI responds fast enough).
There is a library made by Spaceteam that does this for Unity games.
https://github.com/hengineer/CaptainsMess
The creator of Spaceteam also wrote an old blog post about Networking in Spaceteam
http://spaceteamadmirals.club/blog/the-spaceteam-networking-post/
There is an iOS only library that will connect nearby devices easily called MultipeerConnectivity https://developer.apple.com/documentation/multipeerconnectivity
If you want something that will work cross-platform I have an example app here: https://github.com/brendaninnis/LocalNetworkingApp, which I explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-1.html

GameKit Turn-Based AND Real Time Match

I'm working on a simple Game Center Multiplayer game that has two players; the game is set up like a timed chess match, where each player takes a turn, but only has x amount of seconds to act. I think that the timer is necessary to keep players engaged and to avoid long periods of inactivity that can occur with Turn-Based. I've looked at the Apple Docs for both Turn-Based and Real-Time matches, but still can't find a solution to my problem.
Simply, this game has three requirements:
Needs Game Center/GameKit Implementation
Players must take turns
Players must be held to a time limit
What approach is best for this scenario? Real-Time or Turn-Based? Could they be used simultaneously?
I appreciate your help!
P.S. I will probably have a couple of follow-up questions regarding proper implementation.

How to translate two languages at the same time without delay for instance: "two online games written in different languages"

I have a question about writing a script which can manage to play online games in different codes. I think the easiest to understand is when I say I need to make a platform on which Playstation as xbox players are allowed to play online Modern Warfare 3 together.
Mathematically it seems it is possible: at the end you have two different screens which project the same. On the platform, Sony and Microsoft players stream their code or screen to the platform and play together. Big problem is that you get it delivered in 2 different codes which you have to translate to one language in less than 0,001 second.
Honestly said I have to get into this stuff but I cannot get much further.
Do you have any tips, other forums or solutions for this problem? Maybe it is writing a new language? (Google is technically using it for Google-translating over the phone)
Depending on the game this might not be possible even in theory. Many console games use a peer-to-peer lock-step synchronization model for multiplayer. Games that use this approach only send each other the player input from the other consoles and rely on deterministic simulation (the same inputs produce the same outputs) to keep the systems synchronized.
This only works when the exact same compiled code is running on the same CPU for all players. Games with this networking model usually have periodic desynch checks to make sure that the different systems haven't drifted out of sync with each other. A desynch failure is usually considered a fatal error and either a bug in the game or evidence of attempted cheating by one of the players.
Other multiplayer games use a client server model and so it would be possible in theory to allow different consoles to play against each other. Reverse engineering the network protocol would be a formidable technical challenge however and it would be a difficult problem to get this to work reliably.
Even if you could solve the technical problems though you would likely have even bigger legal issues to overcome. Sony and Microsoft don't want to allow cross platform play so even though it would be possible in theory to make this work with a client server multiplayer game developers aren't able to implement it. A third party trying to make this work would likely have to deal with legal challenges from Microsoft, Sony and the game developer.

iOS multiplayer game - what to use for the multiplayer part?

I'm developing a game for iOS that should include the multiplayer. It's not a turn-based, rather a real-time game. I know I can use some different approaches here:
Game Center multiplayer (has matching and searching for matches, gives authentication out-of-the-box, additional are leaderboards and achievements)
As far as I know, OpenFeint also includes some multiplayer helpers
I can also write my own sever code, but woudn't it be reinventing the wheel? I'd also loose all the good stuff from GC...
Any suggestions here? What's the leading market solution, that doesn't take too much to integrate into a game; I'd like to be able to send short bits of data between players (player position + action taken) in a real time. Best would be to reduce the lag :)
personally, i think the easiest way to go is with gamecenter. it was pretty straightforward to integrate it into an existing game - i'd say it took 2-3 weeks. the main problems that we encountered were to do with the game simulation not being particularly suited to multiplayer, rather than anything to do with dealing with gamecenter.
You may also consider Nextpeer (disclosure: I work there). GameCenter is good, but it has the downside of not being cross-platform. We offer a solution that is cross-platform (iOS, Android and Unity3d) and is geared towards multiplayer in casual games. So we provide the hosting, the player-to-player communication, the matchmaking, and Facebook integration.

Resources