i am currently developing a realtime multiplayer game for android and i got the example ButtonClicker working. I think the "quick game"(or maybe it´s called automatch) option is just what i need. But i need something like this: I would like to make the player play a match with a random player from his level. You see, on my game, every player will have a level and these levels and associated players will maybe be stored on a database. I want the player to have a quick game with only the players from his level. Is it possible to inform that criteria on quick game? What must i do?
I also want him to be able to choose his friends(the invite option) but only friends that are on his level.
In order to restrict automatching between players, you can use the variant option when building a room configuration, ie RoomConfig.Builder#setVariant(int).
In order to restrict invitations, I think you will have to create your own "invite player" activity, which I am less familiar with. You will presumably have to query for the player's friends, and then cross-correlate this list with each of their "levels" and filter it down to those of the same level before showing it in the activity. It looks like The Players API has some methods that you will be able to interact with, and hopefully would contain an Id that you use in your level-based DB.
Rob
When you create your RoomConfig for match making you can provide AutoMatchCriteria. The API just uses a bitmask, so it is up to you what data you put in that bit mask:
createAutoMatchCriteria
exclusiveBitMask: Exclusive bitmasks for the automatching request. The
logical AND of each pairing of automatching requests must equal zero
for auto-match. If there are no exclusivity requirements for the game,
this value should just be set to 0.
In your case this could contain a level range to match up with.
You can see it being used in the sample code here: Developing Real-Time Multiplayer Games.
Related
I am new in Appwarp and also in multiplayer gaming. Superjumper is a great tutorial and its methodology seems incredible, but I do not know, how to build MultiplayerGameScreen.java from my own single player game.
Can you please give me maybe a step-by-step instruction or guidelines, how to make this file?
MultiplayerGameScreen.java is a game specific class. All the AppWarp related functionalities are implemented in the WarpController.java class which you can find here. MultiplayerGameScreen.java is just calling the required methods from WarpController.java.
To convert the single player game to multiplayer, you can use the following steps:
All the players who needs to play together must join same room
Once game starts, if player needs to send its information to other players, you can use either sendUpdatePeers or sendChat as per the game requirement
Once a player sends update then server sends notification to other players which you can receive in the corresponding callbacks such as onChatReceived in case of sendChat
Once you get the notification, you can update your game UI accordingly
You can always write to us on support#shephertz.com or on our forum in case of any problem.
In my game I use Google Play Game for Achievements and Leaderboards.
I've just noticed (by logging into the Google API Console), that performing a simple action such as displaying a leaderboard, results in 2 API calls. I would have thought this would be only 1.
I'm simply calling the leaderboard like so:
public void displayLeaderBoard(){
if (getGameHelper().isSignedIn()){
if (leaderboardIntent==null){
leaderboardIntent = Games.Leaderboards.getLeaderboardIntent(getApiClient(), leaderboardID);
}
startActivityForResult(myLeaderboard, 1);
}
}
Note it is still 2 API calls even when pressing the leadeboard button a 2nd time (therefore not creating a new 'leaderboardIntent').
Also, when submitting a high score, it uses 3 API calls (one for submitting, then again it calls displayLeaderboard() to show the player her/his new high score.
The thing here is if I then exit back to the app and submit the score again, it uses another 3 API calls. The documentation states:
Both the Android and iOS client libraries will know not to send a
player's score to the server if your score isn't as good as one you
recently submitted.
I know I could simply store a copy of the high score in sharedPreferences and then not submit it if it's not high enough, but I'm not sure about this - what if the device has multiple accounts set up for example.
I would be grateful if someone with more knowledge/experience of the Play Games API could confirm if the number of API calls I'm seeing is correct and how this relates to quote above, or whether there is something more I should be doing in my code?
The number of calls you are seeing could very well be correct. For many APIs, each request has a "cost" related to it. Which means where a read request to a certain API might cost you 1 call, a write request might cost you 5 (just assuming). Hence, depending on the requests you are making your number of calls are going to differ compared to the number of requests made. For example, try this tool to calculate Youtube API quota cost. Unfortunately I couldn't find any such tool or documentation for Play Games Services API but I hope this makes my point clear.
For optimizing your code to perform it's best, take a look here and try to optimize your code to follow Best Practices as much as you can.
According to the GPGS website-
Use the client libraries. The mobile client libraries employ a number
of strategies to reduce the calls you make to the service. For
instance, achievement and leaderboard data is cached, so a user can
view their achievements as often as they'd like without requiring the
service to make multiple calls. Both the Android and iOS client
libraries will know not to send a player's score to the server if
your score isn't as good as one you recently submitted. The Android
library also automatically combines frequent achievement increment
calls when it detects that you are being rate limited.
I'm specifically interested in 'viewing achievements without requiring the service to make multiple calls'. As far as I can see, the best way to do this would be to use the OnAchievementsLoadedListener and get a reference to the achievementBuffer.
Will that buffer be updated when an achievement state is changed and is it okay not to close that buffer immediately? If not, the OnAchievementsUpdatedListener does not pass a buffer or even and indiviudal achievement reference so how would I get the updated collection of achievements?
I found my answer here:
https://developer.android.com/reference/com/google/android/gms/games/GamesClient.html#loadAchievements%28com.google.android.gms.games.achievement.OnAchievementsLoadedListener,%20boolean%29
Set forceReload argument to false to gain the advantages of data-caching :)
I am planning on introducing Google play game services to my app. However I am not sure if i can provide the following capability. I need to be able to list the rooms available so the player can join any room he chooses rather than auto join.
Is there a way to do that? Thank you
In the current implementation of our API, there are no "open rooms" that you can voluntarily enter. You need an invitation to enter a room. So the method we have that's closest to what you're asking is the GamesClient.loadInvitations() method, which will list all the currently active invitations to rooms that the player has.
If the behavior you're trying to implement is "I want to join a room that's playing upside-down four-dimensional chess", without being specifically invited by a friend, then what you want is probably automatching. Automatching means you create a room and specify the number of players you want in your game and, optionally, a variant code (an integer) that indicates the game type. Then, the API will match together a set of players who is wanting to play that same variant at that moment, and will put them all in the same room.
You might need to use Leaderboards in Android
I can't see how you could do this in the current release of Game Services (at least not if you use the API in the way that Google wants you to).
However I just noticed this:
https://developers.google.com/games/services/web/api/rooms/join
Join a room. For internal use by the Games SDK only. Calling this
method directly is unsupported.
Maybe this sort of thing will be possible at a later date ?
I'd like to have an android app that would allow a given number of users to be "logged in" either as a player or ref. The players would just be able to increment their score, while the ref would have a screen that shows all player scores and alerts the ref with a tone/vibration when a player reaches a target score.
I have no android dev experience and in a perfect world I would just find an app that does something similar to this that I can just tweak. I'm not sure if this kind of functionality would depend on having a server or at all where to begin on learning the knowledge that would be necessary to create such an app.
Kind of a vague question... you will however need a server to keep track of all the scores - for example you can have an SQL database that contains all the users/scores and all the Android app is tell the server which user's count to increment.
Another alternative would be to use the Google Drive APIs - you can probably use forms or something to increment counts while the "ref" would have full access to the document.