KrisF
KrisF

Reputation: 1411

Using Game Center's Turn by Turn Matches for a Game Like Tetris or Bejeweled

I'm building a game similar to bejeweled. I'm planning on integrating Game Kit to allow players to play against a friend. The flow I'd like is:

I think Game Kit's turn by turn is the way to go. But this isn't really a turn by turn game so it isn't perfect for this usage.

Being that I don't want player 2 to have to wait for player 1 to finish before he can start, I'm thinking I can make player 1's "first turn" be to simply send the board state to player 2. I don't want player 1 to have to wait on player 2 to finish before he can begin playing though.

I'm considering two approaches so far but I'm hoping someone else might have a better idea.

Approach 1: Player 1's "first turn" is to send the board state to player 2. Player 1 can play the board now and his score is stored locally with the key to retrieving it being the match number. Whenever player 2 is finished, his score is sent inside the matchData back to player 1. Player 1 is notified it's his turn. When he reopens the match, his locally stored score is retrieved and compared to player 2. The winner is declared at this point. This isn't ideal because player 1 has to log back in even though he's already finished playing.

Approach 2: Like approach 1, player 1's "first turn" is to send the board state to player 2. Player 1 can play the board but now his score is posted to a Rails server (or maybe something like Parse.com to simplify it). After player 2 finishes his turn, an api call is made to see if player 1 has finished. If he has, the score is retrieved and compared and the winner is determined. If no score is there, player 2s turn concludes and control is passed back to player 1. When player 1 finishes, the 2 scores are compared and the winner is determined. The only issue here is I have to create a backend when I'd rather not.

In any case, suggestions are appreciated! Thank you.

Upvotes: 2

Views: 370

Answers (1)

rickster
rickster

Reputation: 126127

I'm not exactly an expert on Game Center, but the turn-based match support sounds like the wrong tool for this job.

Your kind of asynchronous multiplayer sounds a bit more like what you see in Jetpack Joyride as demoed in WWDC 2012 Session 500 (Game Technologies Kickoff -- it's about 10 minutes into the video). They use the new "score challenges" feature of Game Center, but augment it by providing a ghost of the other player to race against. They do this by recording your race and, when you challenge another player, uploading the recording to their server, where it's identified by a 64 bit value they store in the context field of GKScore. When your friend accepts the challenge, his copy of the game pulls that value from the score challenge and uses it to look up and download the recorded race data from the server.

Upvotes: 1

Related Questions