Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Disclaimer: my goal is not to use cross-platform frameworks like Unity.

I am currently planning a mobile game which I intend to first launch on iOS. However, I am wondering if it is better to write everything in Objective-C, thus locking the code into the platform, and to do a complete rewrite for other platforms (ie: Android). The other option would be to write the game logic in C or C++ and to only write the code that interfaces with each OS in the preferred language (Objective-C(++) or Java).

I understand that this must depend on the size of the code base, so what program size should mark the separation? Finally, if I write cross-platform code, should I stick to C (since Objective-C is a superset of C, making it easy to use C and to use the code samples and because the NDK and the JNI interfaces are more C oriented)? The only advantage I see with C++ in that case is the fact that it is object-oriented and thus it is easier to represent game entities).

share|improve this question
    
Unity basic license for Android and iOS is free for a few weeks.. I realize you seem to be against it (assuming cost) but once you write a few apps for a specific platform, you may change your mind. –  Rubber Mallet Mar 12 '12 at 3:26
1  
@RubberMallet There are tons of reasons not to use Unity, "assuming cost" is a wild and likely wrong assumption. –  Lohoris Mar 13 '12 at 13:55
    
Stating that there are 'tons of reasons' for or against any platform sounds a bit fanatical. I would be interested in knowing what you are thinking of specifically. Any platform is strengths and weaknesses but not everyone has thousands of dollars for pro licenses and such. Unity is a good platform for certain games but obviously it's not for everyone, I realize this but it may be worthwhile unless you want to handle significant plumbing on your own... –  Rubber Mallet Mar 13 '12 at 18:05
add comment

5 Answers 5

The "worth" of something can only be determined by you. For some people it isn't worth porting to android for the amount of time spent vs. sales.

That being said there's no reason to just use C++ for everything. Sure, the interfaces for certain things is C or Objective-C, but you can call both of those easily from C++.

share|improve this answer
    
To counter the argument at the end of the linked article, I have talked to a handful of mobile developers that all share the same rhetoric, if you are looking to make an income from mobile development you should target iOS. The Android market has proven itself to not be as willing to pay for what the iOS market will. –  James Mar 11 '12 at 19:54
add comment

I'm into XNA for Xbox360 development, and some of the developers that have written games for Xbox and PC in C# reported that porting to C++ and other platforms wasn't very hard at all.

Full portability is probably not a good idea, as the UI should be tied to the platform. This means you'll probably need to design specific UIs for iPad, iPhone and various Android devices.

The game logic on the other hand, can be written in such a way that it does not reference the OS directly, allowing to share the code among platforms, or at least make it painless to port between languages and platforms.

Finally, it's worth mentioning .net and C#, which are available on PC, Xbox 360, iPhone/iPad (mono touch), Android (mono for android), Windows Phone 7 and PlayStation Vita. That's quite a wide range of platforms.

share|improve this answer
add comment

You could rewrite everything for both platforms, but that would take a lot of time. Another option is, like you suggested, to write the OS dependent code in Objective-C and Java and then write the core of the app in C. If it is a little app, then the first option shouldn't be too much of a hassle, especially if you're just embedding a web page or something similar. But for larger apps (ex. 3d multiplayer games) the second option is better. You said you didn't want to use a cross-platform framework like Unity, but if you went with the second option you'd essentially be writing your own library. If your game requires a lot of OS specific things than this could be difficult to implement as well. And there are some frameworks which do almost exactly what you said (implement OS specific stuff then let you use C or C++ to write code) like MoSync.

As for C vs C++, if you really like C++ and can't stand to code in C, then it's worth using C++, but otherwise I'd say stick with C because it could be very difficult to use C++, though I don't know for sure. I'd look into using C++ with the NDK.

share|improve this answer
add comment

While this falls in line with some of the other answers, I'll make this case: Cross-platform development can mean not only two different platforms at the same time, but also the same platform at two different times.

By that, I mean that every line of code that depends on a platform/OS specific feature is one that will have to be rewritten should the exposed functionality of the platform be changed at a later date. If you keep your codebase platform agnostic, you only have to worry about updating the OS abstraction layer to accommodate new changes.

share|improve this answer
add comment

you definitely want to think cross platform. iOS may be most lucrative now but a lot of developers are now quietly moving to Android. if your game is successful, you will want to localize and release in other markets and, for example, Asia is more of an Android world.

There are platform independent toolkits, like Unity, so investigate those. You also have HTML5 as a possibility.

bottom line is this - if you are successful, you will want to go cross platform. If you are not, that could also be because you did not try all platforms. so better think cross platform right away :)

share|improve this answer
    
-1 This advice is just unsubstantiated assertions. There are no figures presented, there is no insight into why people might be moving to Android (maybe they are not even going cross-platform), and the answer never actually addresses why someone would want to do it. It just asserts: "Well, some people are doing it. If you are successful, you will want to do it." (okay, I hear you, but WHY?) –  Jonathan Hobbs Mar 12 '12 at 3:46
    
-1 he said, in the very first line, his goal was not to use frameworks like Unity... and you suggest just that. –  Lohoris Mar 12 '12 at 8:19
    
@JonathanHobbs omg! what a way of welcoming someone new! "there are no figures presented" - ok, sorry, next time I will not answer till I have figures. "okay, I hear you, but WHY" read it again –  Greg Bala Mar 13 '12 at 13:41
    
@Lohoris sorry, i missed that –  Greg Bala Mar 13 '12 at 13:44
    
@GregBala Being new doesn't stop your answer being bad. Your answer is bad, so I have given it a -1. –  Jonathan Hobbs Mar 13 '12 at 14:06
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.