You are here

How to make your own Android Game

In this article, I will describe all necessary steps required to produce and publish an Android App of your own.

I will write this article in the form of a log of what actions I do myself while I prepare a development environment and write a simple clone of an arcade game from the golden era of the late 70's.

This means that unlike most other tutorials, this one will also include all the "lessons learned", the typical pitfalls and the common mistakes. Hopefully so that you don't have to repeat them yourself. ;-)

 

My development platform is a minimal netbook (Acer Aspire One). It is actually possible to use it as it is (I did that when I wrote my first few apps) but it is really painful with the default 1 GB. I paid €200 for the netbook, and for only €30 more you get 2 GB. Note that the pre-installed Windows 7 Starter only supports 1 GB, but a change of OS is more or less mandatory anyway ;-)

The screen is also painfully small when you prepare the development environment. Some of the GUI:s put the OK and CANCEL buttons below the bottom of the screen. It is still possible to navigate with the TAB-key, though.

 

I refer to Ubuntu Linux in the first chapters of this book/article. Android development is just as easy in Windows, but I just happen to prefer Linux..

 

Happy Reading!

 

/Anders Ekstrand

Comments

I have gone through this code many times. When I fire a missile the game crashes...sometimes splits the asteroid in two pieces and then crashes immediately..Any idea where I am going wrong. It is somewhere in the asteroid or missile routines i suspect

ajo's picture

Just for the records: JohanD sent me a copy of his Eclipse Project, and it showed that the issue was that a highlighted version of the missile bitmap was missing.

This caused a NullPointerException in a getWidth() call.

I want to add gravity sensor to my game
like If there are some balls in the game so it moves in the ground direction when we are playing the game
I think you must get an idea what I want ? now tell me where and what to add or it is pre- installed
Also I am doing it in windows 7  please reply soon

ajo's picture

Hi Deepal,
 
What you are describing is the first piece of a physics engine.
 
Eventhough it is not directly rocket science, it would take up a number of articles of its own.
 
If you google on "android basic physics engine example eclipse" you will find a few references to start with.
 
BR - Anders

Hi Anders, I just stumbled over your page and saw that you used my asteroid image. I really like the way you use it. Thanks for the credits.

Also: good job on this tutorial!

Martin Felis

ajo's picture

And you're welcome ;-)

/Anders

Hey Anders! I've been following your tutorial and first thing's first: Congratulation. It's absolutely amazing, very well explained.
I have a problem when executing the game. It usually crashes whenever a missile comes into contact with an asteroid. Like I said, it usually happens, sometimes I get lucky and I'm able to pass to level 2, but never farther than that. Any idea?
I can send you my Eclipse project if needed. Thanks a lot in advance!

ajo's picture

It seems that I made a mistake when I added highlighting of objects that are flagged as "collided" in GfxObject.draw().

Just comment out that part to get rid of the problem you reported:


public void draw(Canvas canvas, float x, float y, Paint paint) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.rotate(angle, x, y);
// if (collided) {
// canvas.drawBitmap(bitmapHighlighted,
// x - bitmapHighlighted.getWidth() / 2,
// y - bitmapHighlighted.getHeight() / 2, paint);
// } else {
canvas.drawBitmap(bitmap, x - bitmap.getWidth() / 2,
y - bitmap.getHeight() / 2, paint);
// }
canvas.restore();
}

Hi Anders, love your Tutorial so hard to find reference material on Android development.
 
I am new to the seen and had a great time using your code, I have an issue with the ads, if i remove all the ad code the game works unless i press the How to key, also have an issue when i press the back key wether it be from the credits screen or in game the app crashes any thoughts, i have looked over the code several times and only have the warning about the @string/ references, it would be great if you could explain how you would use a paragraph in the string form ...... i mean if you have time, hope i don't sound pushy or ungreatful like i said great work.

ajo's picture

Hi James,
I can't promise anything, but if you could send me a copy of your source project I will see if I can find the issues for you.
 
BR - Anders

This guide is fully informative. It is great for newbies like me to make an apps for android. This will help me guide through developing my own games. And ofcourse make a profit out of my own games. This guide is really amazing. Thank you for sharing this wonderful guide. [a]Noypiwap.net[a/]

meenmic8's picture

I have been looking for a tutorial like this.  Thank you!  I will definitely visit often.
(I also clicked many times on the ads as support).  Very appreciated.

Hi.

 

I'm a Computer Science student now, 4th year.
our thesis is all about adroids application sir, and we and my groupmates have no idea about this issue, about what will we do about making the title first. we have no idea about to make a title.

this sample adroid application that you made, i appreciate it, but we cannot do that and make that same thing, because we need to defense it, and our topic from first year to third year is all about turbo c, html, php, visual basic. 

ajo's picture

Hi there,
 
I'm not sure in what way I could help you.
Your'e free to use whatever parts of my example you want, but I can't really help you come up with other ideas.
 
Best Regards - Anders

Hi Anders,
Which software you used for the sketchs.  

ajo's picture

Hi,
 
I used a rather nifty online tool for that:
Sketch & Paint! - http://www.onemotion.com/flash/sketch-paint/
 
BR - Anders

Abu Khalid's picture

How to add sound onTouchEvent  for Ship. Can you help me?
 
 
Thanks
Khalid

ajo's picture

Hi Khalid,
 
I didn't cover the concept of audio in this tutorial, as it almost is a domain of it's own ;-)
 
But a good start is to read the documentation on "android.media.AudioManager" and "android.media.SoundPool".
It should give you something to start with.
 
Best Regards - Anders

lon3lymind's picture

great tutorial sir,...same questions here, can you help me figure out how to add sound in touchevent for "ship" and in collision detection for "asteroid" ??
and add BG music and BG Images for gameactivity??
i'm sorry for asking too much question, i'm begineer in game developing

Thanks in advance,..

ajo's picture

Hi,
 
Please refer to the above comment.
 
(Basically, you pre-load all your sounds into a SoundPool when the game is started, and then you have a static instance of AudioManager that you call to start and stop them at different events.)
 
BR - Anders

Abu Khalid's picture

Only the last missile hit it's target. you do not sovle it . So I do not ahead . Please you you solve this problem. I waiting for you.

ajo's picture

Hi Khalid,
 
The game works for me, and I copied and pasted the code from Eclipse into this forum.
 
Do you see any stack traces if you check the logs with LogCat while running the app?
 
BR - Anders

jupli's picture

How to make world puzzle game ? what is the first time should be prepared ?

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer