[Native C++] Join random room with player properties?

Options
zaki
zaki
edited May 2015 in Native
Hello guys,

Newbie here. I have a couple of questions regarding multiplayer realtime game. Please advise:

1. How to join a room (be it random or specific) with custom player properties?

2. I want to do like a simple tank wars game like this. Player plays as a tank. In a room probably there are 2 - 10 tanks. The last survivor win the game. My question is, when I shoot an opponent. What information i should broadcast (my current implementation is like this):
- Tank 1 shoots tank 2. Tank 1 call opRaiseEvent to Tank 2, Tank 2 receives damage and using opRaisedEvent again to broadcast to all that Tank2 hp is reduced by 10. Is this a correct way?

3. Lastly, is there any example (LoadBalancing) project for Objective C. I downloaded the iOS SDK v4-0-2-1, inside comes with few demo projects. Some uses cocos2dx, some are c++. I really need a demo for Objective C load balancing project (I am sucks at c++, especially using pointers).

Thanks in advanced.

Comments

  • Kaiserludi
    Options
    Hi zaki.

    1.
    Set those custom player properties on the MutablePlayer reference that gets returned by Client::getLocalPlayer(), before calling Client::opJoinRoom() or Client::opJoinRandomRoom(), please.

    2.
    Can't tank1 already calculate what damage it's hit caused on tank2?
    In that case it would make sense to just let tank 1 broadcast to everyone else in the room that it has hit tank2 for X hp.

    3.
    The v4 native Client SDKs currently do not ship with an objC API at all, as v4 of the objC API is not yet in a ready for production state.
    For an objC API plus accompanying demos please go with with the latest v3 release of the iOS or OS X Client SDK, for now, please.
  • zaki
    Options
    Hi Kaiserludi,

    Thanks for tbe quick reply.
    One question just lead to another questions, hope you dont mind.

    1. When will v4 native obj c be ready for production state? Estimated time? I want to know because I need to consider should I continue using c++ or wait for obj c.

    2. Are there a lots of differences betweet v3 and v4?

    3. Which version do you recommend me to use since i am more familiar with obj c?

    Thanks again.
  • Kaiserludi
    Options
    Hi zaki.

    1.
    Sorry, but we don't have a release date yet. It may take a couple more weeks.

    2.
    You might just want to have a look at the release-history files of the 4.0.2.1 SDK and read what has changed since the last 3.x SDK.
    The most important changes are the following new featues:
    - a dedicated Client API for Photon Chat
    - trafficStats and interest groups
    - a lot of features for better support of turnbased games have been added to the LoadBalancing API

    3.
    In general I would prefer C++ over objective C mainly because you then can share one codebase over multiple platforms: We offer C++ clients for a variety of OS. Originally iOS-exclusive games very often later get ported over to Android. Photon-related C++ code that you have written for an iOS game will just run on Android without any code changes, as long as you use the same version of the Photon Client API on both platforms. Just let your project link to the Photon client SDK for AndroidNDK instead of the one for iOS and you are done. When your codebase is in objective C, then you would have to port it to Java or C++ to get it to run on Android and afterwards for any update of your app your would have to adjust 2 codebases in 2 different languages. That's why I personally would recommend to have as little as possible of your code-base in objective C or in swift.The more code your write in languages that are practically only relevant on one platform, the more effort it will be to port your game to another platform later on.

    In your case of course you would have to weight that porting advantage against the learning time needed to get better with stuff like pointers.

    However if your preferred choice is to use the Photon 4 objC API in the future and you don't need any of the mentioned new features immediately, but can wait for it for a few more weeks, then it would definitely make more sense to start with the Photon 3 objC API for now and to update your code to Photon 4 later on. Likely you will only have to make small adjustments in your code when updating.
  • zaki
    Options
    Hi Kaiserludi,

    Thanks for the detailed explanations, especially the 3rd question answer. It helps me a lot. I like the porting advantages idea, however, the project has a quite tight timeline. I need to think through it.

    Thanks again for your help. Have a nice day.