Android Game development

Started by
9 comments, last by coder_for_life23 9 years, 3 months ago

Hy guys i`m looking into learning a new language to code games for android, i`m in between c++ and java (cocos2d-x and libgdx), i`ve already made a game using python and kivy and uploaded it to google.play ,but could not monetize it, since i`m quite new to programming and there were no good solutins for it, so i`m looking for something with a bigger comunity , support and solutions. I`m interested also what difference is there between the two in terms of difficulty and learning curve.

PS: i don`t have a computer scince degree so i`m not loooking for a language to help me get a good job, just to make games , mostly for android.

Advertisement

As far as I know there is a huge demand on C++ programmers for mobile game programming, since this language can be used both in Android and Apple devices. If I were you, I would try to learn cocos2d-x and later I would go straight to OpenGL ES 2.0 + C++. Later approach will give you much more understanding of underlying infrastructure and hardware capabilities.

Notice, that there are alternatives:

1. Unity3D, which, in my personal opinion is subpar. Best for making prototypes, but complex games require you to completely change workflow and write a lot of customization code for serialization and other vital features. Not to mention that it is very buggy, crashes a lot. Once it completely erased our Assets folder, where all of our game assets were stored. Personally, I wouldn't recommend it to anyone.

2. Flash+Starling on AIR platform. Really nice mature framework, which is accelerated by GPU. However, AS3 will not be as useful for you as C++ or C#.

3. HTML5, which is useless, unless mobile developers incorporate asm.js into their browsers. Considering that even WebGL lacks support on mobile devices, I wouldn't expect it to become available even in middle-term perspective.

I completly disagree with GuardianX

The difference between Java and C++ is mainly that C++ is the mighty mother (to be exact it is C but C++ is the better C) of nearly all popular languages out there. There is nearly nothing you can't do with C++, it even inherits most new language technologies from other languages.

However that makes C++ very heavy, redundant, repetetive and complicated. There are 4 (or 5?) ways to initialize a variable while the language itself lacks of newer innovations like from Java and C#. It is years behind.

Your case really cries for Java!

Advantages

1. It is nearly as fast (in some cases even faster) then C++

2. It is a very intelligent and fast to write language and propably one of the most innovative ones

3. It is purely designed to write code fast, efficient and fail safe

4. It has a lot of libraries.

5. When reading the C++ documentary you are going to read something like this very often "This action can be very dangerous and can have unpredictable results" - not in Java, completly fail safe.

6. If an coding error happens in Java during runtime or when compiling you are always told exactly where the error happend, what happened and why.

This is not the case in C++, it makes you often really search for the error and the hints it gives you are not always correct. It is not bad but in comparison to Java it lacks a lot.

7. It has features like auto-import. If you want to use a library in C++ you have to manually write it on top of your code, in Java it automatically imports those functions.

This saves a lot of time and performance. Also other auto-completion tools

(I have no idea why this doesn't exist in C++)

8. Java has great IDEs like Eclipse or IntelliJ with millions of plugins. Eclipse is also available for C++.

C++ has VisualStudio, crappy, slow, little bit buggy software with a lack of proper tools.

9. The Java compiler is REALLY fast. C++ needs a while to compile. So for testing purposes you can just alter a variable and start your program over and over again to see what happens.

I don't want to start talking about C++ in this matter but it gets really painful there.

10. Java as well as C++ can be used on nearly every platform. However Java is not available for IPhones.

When coding carefully with C++ you can compile it nearly with no code corrections for other systems.

In Java you can just run your already compiled program on every machine, though porting between Android and PC is not possible due to a different VirtualMachine (Java and Dalvik).

There are many more advantages of Java over C++ but I risk repeating myself, so I say it one last time:

Java is a fast coding language due to it's automatic tools, intelligent fast compilers, intelligent overall languages, it is fail safe and you have a lot of auto-imported libraries at your service.

It is also very good and fail safe when coding in a team.

Disadvantages

1. No Unity, a powerful game engine. There are of course Java Android game engines, but Unity is outstanding from all free engines out there.

2. If you learn Java first, it is really hard to learn C++ as you have to "reduce your life standards" because of the reasons above. It is easier to learn C++ first and then change to Java, because both languages share nearly the same syntax and Java is a lot easier then C++. When learning Java first and then C++ you are going to think the words "WHY THE HELL DO I NEED TO DO THIS!!?!?" very often.

3. Java is strictly(!) OOP. This is actually an advantage because the language is forcing you to a specific, strict and clean coding architecture which is also an advantage when coding together with others, however it can be an obstacle for beginners to OOP to understand the concept and design their code in this direction.

C++ 'supports' OOP, however It lets you circumvent the restrictions which leads to bad code but you don't need to start from scratch or recode big architectural decisions made before because you planned in some design decisions or features which were thought of later in development.

So you are basically crying for Java! "Just to make games".

Thanks a lot for the answers, I think i will go with java and libgdx, this path seems easier, and more productive.

Have a look at HAXE/OpenFL.

It is sad that you have chosen dead language in gamedev, but apparently you want to go that way. Whatever. Sadly I don't have enough time to blow all of the points which AppropriateUserName provided.

He clearly haven't seen any benchmarks, doesn't know that C++ is multiparadigm, thus you don't pay for what you don't use, doesn't know about Turing-complete compiler, templates, RTTI, RAII, lambdas and proper memory management, not rudimentary GC which will kill the app in most unpredictable way possible. Praising Eclipse - the most unstable piece of sh** I ever used. Especially compared to VS+VA. Java is for business and server apps (the later is questionable lately).

C++ will give you the power of native machine. Again, you don't have to mess with everything C++ has to offer - and it offers much more than Java - this is why most of demanding applications are written in C++. All desktop and console game clients are written with C++ and C. There is no place for Java in performance-narrow applications, such as games.

I personally hate Java.

Java was a good idea, then Sun buggered it up.

The idea of java was for a platform independant coding platform, someone else wrote the JVM for you and your code ran on top. This gave you the platform independence and WORM (write once, run many) functionality we would all like.

Then they started buggering about and we ended up with PJava, Midp, breaking changes in every JDK, and all of a sudden the WORM functionality went away. You are now back in the situation of having to rewrite code on a per platform basis. The very reason for java disapeared up it's own posterior.

Java has always been slower than native code, java will always be slower than native code, but over time they have improved the performance of the JVM so that for a lot of use cases the performance is good enough. I personally don't think it is good enough for games, but that just my opinion. Other people are happy enough with the performance for what they want to do.

When it comes to Android development you have another issue to consider.

OpenGLES is NOT A STANDARD!

This is a fact that a lot of people don't understand. Just because OpenGLES <insert version here> supports <insert feature here> , it does not follow that all devices support that feature.

Sadly Khronos were wimps when they started putting it together. Every time a manufacturer said "that's too expensive to support" they just lay on their back with their paws in the air and said "ok we'll make it optional".

This is a major issue when you want to write high performance games on Android. Typically problems in asset streaming and shader support can cripple development.

This issue for me means that C++ native games on Android can only be the supported by pro teams if you want to support a range of Android devices. If you only want to target a single platform, you would be fine and you may find it runs on a bunch of other platforms as a bonus. It's not a given though.

Since most of these issues will be "hidden" by working in Java, you are probably better working in Java. Though I hate to say it. Having written a JVM I know very well how crap it can be.

Hey guys thanks a lot for the answers, GuardianX sorry for downvoting you it was a missclick and couldn`t undo, anyway , I am pretty in-between, java seems a lot easyer to work with but when i think about Sun and Oracle i tend to want to go the C++ way.

However C++ could also compliment my knowledge of python which i am getting quite confortable with.

Java on the other hand seems quit friendly for beginners, and more productive. Really in a dilemma:).

The idea of java was for a platform independant coding platform, someone else wrote the JVM for you and your code ran on top. This gave you the platform independence and WORM (write once, run many) functionality we would all like.

Then they started buggering about and we ended up with PJava, Midp, breaking changes in every JDK, and all of a sudden the WORM functionality went away. You are now back in the situation of having to rewrite code on a per platform basis. The very reason for java disapeared up it's own posterior.

Pure Java is still platform independent.

I have once written a local vocabular trainer (with a GUI of course) working together with an online server.

I developed the program completly on Windows 7 including testing and and didn't cared at all for other platforms as I didn't had them.

When I released it, it worked without any problems or any other different behaviour on Linux, Mac and of course Windows.

The only problem I had was that on Macs it didn't displayed some characters correctly for some languages as the server was a Windows server and send the vocabulary in a different text encoding.

As I said already above, Java and Dalvik(Android) are not independent from each other. You can't just run a .jar on a mobile device.

This is mainly because Dalvik uses some slightly different important libraries then Java, and Dalvik is from Google and not from Oracle.

Java has always been slower than native code, java will always be slower than native code, but over time they have improved the performance of the JVM so that for a lot of use cases the performance is good enough. I personally don't think it is good enough for games, but that just my opinion. Other people are happy enough with the performance for what they want to do.

You are absolutly right.

Though Java is pretty fast and it works very well for most games, it would be propably totally misplaced in todays AAA titles.

Java is able to use C++ functions with the Java Native Interface (short: JNI) so if you find bottlenecks (which is done normally at the very end of development) you can very well replace them with C++ code and see if it is faster.

The drawing part is on Android already covered with native OpenGL if TO is even going to use that.

As a side note: Java is based on C/C++ and so C++ is logically always faster then Java when calculating in an unlimited amount of development-time.

Javas standard libraries like Threads and Memory allocation/deallocation are faster then the standard C++ ones and even totally automatic. Why reinventing the wheel which was forged 20years long for a simple game?

I think one of the main disadvantages is how many ressources (RAM mostly) Java needs to run. The whole JVM has to start first, load up ressources and everything takes up a lot more RAM.

My current OpenGLES 2D game I am working on (running in pure Java (and performance is totally fine)) has a really big tiled landscape (1024x1024 tiles (in RAM at the same time)). When increasing this size a little bit more I run out of memory on my mobile device, however the same code written in C++ can allocate four times as much (2048x2048 (in RAM at the same time)) as .

However when comparing both performance-demos with one another I needed for C++ about 3 times longer to write the code and counting the lines I wrote a lot more in C++ to get it working. And it is not like those are logic lines, no they are redundant because I need to write i.e. for the compiler the method name twice a the top of my file so that the compiler knows that it exists (it gets more funnier when I decide to rename my methods afterwards) -.-

Life is always a two sided coin. Java is also not a very easy language or the praised holy language but it is much more comfortable to write and powerful enough for games and everything else you need.

Since most of these issues will be "hidden" by working in Java, you are probably better working in Java. Though I hate to say it. Having written a JVM I know very well how crap it can be.

That is very interesting. A JVM on your own? I always wanted to take that task by myself but... well... somehow I never started.
You have no idea how many questions I would like you to ask now, I think this is a very interesting topic biggrin.png

My dentists always tell me how they are scared to go to the dentists themselfes as they KNOW what right now happens in their mouth and they would rather not know like everyone else. (That is definitly not a joke as my sister became a dentist now and told me the exact same thing). Well that is the burden of "knowledge". biggrin.png

Best Regards

Just, you know, use whatever works for you. You're not going to make Skyrim on your own (wait, I haven't been playing a lot of AAA games lately, what's the current example?) Your biggest project hurdle will not be the performance of your programming language, it will be the likelihood that you'll actually complete the project.

So don't make it hard on yourself. Use Python, or Haxe, or Unity3D with JavaScript scripting, or whatever you think you're most comfortable with. Will it be "OMG ZOMG BESTEST GRAFEX EVAR!"? Nope. Will it matter? Equally nopers on the nosers.

As you grow as a programmer, you'll find you have needs that your current programming language doesn't fulfill. And that's any language. And you'll find it ebbs and flows over time, like today C# is the best language for you, tomorrow it's Ruby, next year it's C# again. Don't sweat it. Just go with it. In 5 years, you'll know 10 languages. In 10, you'll even be good at one or two of them. In 20, you'll forget which languages you even know and they will all start to blur together as you slip in and out of each like carving sick moguls on a ski slope. Or something. My metaphors aren't good today.

Super Mario Bros 3 was a high water mark for me in gaming. Haven't played many platformers since then that have even come close. Maybe Super Meat Boy, but then again, maybe not. That ran on a 1MHz, 8-bit MOS 6805 processor. Today, you have probably 2 to 4 processors in your phone that are each easily 2000 times faster. That's a lot of times-faster in which to fit high-level language overhead. Nowhere near all of that is attributable to "hand-written ASM". We've got optimizing compilers these days. You can't write ASM as fast as your compiler can make code.

All I'm saying is, if your game sucks, if it's slow, if it isn't fun, it ain't because of the programming language. Take it from someone with a lot of unfinished projects: don't waste your time on this meaningless stuff about what programming language to use, and don't waste your time with these people who will call you an idiot for your choices. Learn good habits, one of which being how to finish projects. Sounds like you're off to a good start.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement