The Development of Tanks War Mobile Game based on Android System

Along with the rapid development of mobile games and the popularity of Google Android operating system, the Android mobile game designed for recreation, exercise thinking will become mainstream. This paper mainly introduces the development process of mobile game and analyzes the key technologies in combination with development of tank war game based on Android system.


Introduction
With the popularity of the Android operating system and the large increase in the number of the terminal equipments of Android system, the application development based on the Android application system have attracted more and more developers.The mobile game development has always been the most important part of mobile development.The development of Android application layer is based on Java development, so it has the advantage of transplantation games by J2ME development quickly.But transplantation of game can't play unique characteristics of the Android operating system.The market based on the Android game development is not enough mature.It is very necessary to develop a tanks war mobile game which adapts to the Android completely on the basis of understanding of the Android application development.

Introduction of the Android System[1-3]
Android is the open source operating system of intelligence mobile phone based on Linux platform developed by Google.It is the first open operating system for the mobile terminal.The Android SDK provides the necessary tools and API for Android application using the Java language on the Android platform.
Android system architecture is divided into four layers.They are application layer, application framework layer, system runtime library layer and Linux kernel layer.

Application layer.
The application layer contains many core applications within the Android platform, such as Email client, browser etc.These applications are to use Java language to programming.The program running on the virtual machine and all application software belong to the application layer.

Application framework layer.
Application framework layer uses API framework to develop the core application.Developers can also use the framework to write their own applications.

System runtime library.
System runtime library layer: when using the Android application framework, the Android system will use C/C++ library to the individual components and make it better service for developers.

Linux kernel layer:.
The core service of Android system is based on Linux2.6 kernel.Such as security, memory management, process management, the network protocol stack, and driver model all rely on Linux2.6 kernel.
Usually a complete Android application includes four components: activity, intent receiver, service and content providers.The Activity component is the user interface.An application usually contains more than one Activity.They are stored in the Activity stack following the principle of "advanced" to switch to each other.When decided to use the above which components to build Android applications, it needs to be registered in the AndroidManifest.xml.This is an XML configuration file.It can declare the application components and their features and requirements in this file.This configuration file is necessary for each Android application.

The game plan
Tanks war games which is a mobile entertainment games can bring joy to people's life.The rules of the game is simple.When start the game, players control their own tanks and use the direction key to control the tank movement.When the enemy tanks began to appear, Player can press the "OK" button to launch the bullet.After all enemy tanks is destroyed, the player wins and the game is over.Enemy tanks have been firing bullets to the player's tank.When the player's tank was hit by a bullet or our home was destroyed by a bullet, the game over.

The Design of System Module.
According to the function requirement analysis, tanks war game needs to complete the following functions: the layout of the game interface, the control function and other auxiliary function.
The overall module structure of tanks war game includes main interface module and control module.The main interface module mainly can give the player the first part of the senses after entering the game.It includes the interface of game graphics area, the display of players and enemy tanks number, the update interface of score display and initialization display of obstacles and base camp.
The game uses "OK" key to start.After started the game there will enter an initial interface.There are player tanks, the walls and the warehouse in the interface.The tanks can't be controlled.When press the "OK" button, player tanks begin to accept control the movement by up, down , left and right key.Press the "OK" button to launch the bullet.When the player is launched by enemy bullets or home is destroyed, the game is out of control.At the end of the game, it will automatically pop up a dialog box.The dialog content is " oh! You're lost !"

The building the game's interface
In order to build the game's interface, it includes the drawing of our tanks and the enemy tanks, the bullet, the retaining wall and the warehouse.In tanks war game GamePanel class is inherits from the View class.The View class is mainly used to display the View, decorate the canvas, provide drawings button touch screen events and functions, etc. Gamepanel class is responsible for rendering initial main interface and accepting the collision events of the bullet.According to target of bullet impact, it will call corresponding functions of Tank class, Shells class or Wall class respectively.

The movement of the tanks.
In order to move the tanks, it can use the following two ways.One is to use a thread to implement multiple tanks movement.This method has the advantage of stable performance, but some operating more trouble.It has a certain understanding for thread.Another is to use Iterator to implement multiple tanks movement.It uses Iterator to access the various elements in a container object and does not need to expose the internals of the object.In this paper, it uses the second method.
The movement of the tank using the up and down or so key control.View class encapsulates the touchscreen monitor function onTouchEvent (MotionEvent event) The event preserves the touch screen motion.Through the getAction function it can get press or mobile operation, which can control the movement of the tank.

Operation mechanism
Every game needs an engine to promote the operation of the game.Tanks war game's engine uses a thread to the Iterator container elements to perform the corresponding action, until our tanks are destroyed or our base camp is destroyed.Through continued remove and draw of obstacles, tanks and bullets, it maintains the update contents in the main screen displays until the player tanks or home was destroyed.

System Development Environment
Android Virtual Device is to debug their Android applications for developers.It can run on the PC.It provides the mobile phone user with the interface and operation way as real shape.It is just different from underlying hardware drivers.Developers can use the mouse instead of mobile phone on the AVD points.
To realize all this, the developers need to set up an Android development environment.The development environment of tanks war game is using Microsoft Windows 7 operating system + JDK + Eclipse + Android SDK development environment.Android game development environment includes the following three parts:

JDK.
The JDK (Java Development Kit) is Sun Microsystems products for Java developer.The JDK is the core of the Java.It includes the Java runtime environment, Java tools and Java class library.The JDK is mainly used develop Java applications on mobile devices and embedded devices.It contains some basic components and common packages.

Eclipse.
Eclipse is an open source and extensible development platform based on Java.It is just a framework and a set of services.It can build the development environment

Class Module Design.
Developed source directory of tanks war mobile game is shown in Fig. 1.

Fig.1 the source directory
GameFactory.java is to create bullets class for tanks fire.GamePanel.java is the class of the main interface and control class in the game.Point.java is the coordinate class.Shells.java is bullets class which contains the bullet movement method.Tank.java is tank class which includes tanks image reading method and moving method.Wall.java is obstacles class which contains the drawing method of the obstacles.

The Implementation of the game interface
The main window is the human-computer interaction.In the program it can create a window which inherits from the View class.

The creation of the game main interface
Creating GamePanel class is used to initialize, add and store the various components in tanks war games.Map[] [] is used to record the current state at every point.It uses initial Map() function to initialize the walls and the base camp.

The draw of the bullet method
Creating Shells class with public void drawShells() method to realize the bullet drawing.

The drawing of a single wall
A unit of wall is made up of a blue rectangle and a white border.It calls drawWall() method to draw a single wall.

The drawing of tanks
It uses the external material pictures.Drawing is first to read the external image.It uses tank overloading function to draw the initial player tanks and the enemy's tanks in the process of the game.

The Implementation of the control Module.
In the main window the game can input and output data.Tanks need to be get four direction movement of up, down, left and right.The "OK" key controls tanks to take fire.

Tanks move
The game must support multiple tanks movement at the same time.It uses Iterator and ArrayList method to operate each element in the container.It implements the enemy tanks movement randomly, and the behavior of judgment when the bullet touch the tanks.

Tanks to generate
Player tanks are generated at the start of the game.The enemy tanks are randomly generated in the certain coordinates range in the process of game.The enemy is only three tanks.

The realization of the bullets function
When a player presses the "OK" button, it will launch a bullet from a tank or when the enemy triggers tanks random events.The bullet will move along the emission direction beyond borders or touch.

Initialization of the map drawing
The game uses a map to express the battle scene.The point of map in the game has four states.It respectively is the idle state, occupied by a tank, occupied by a obstacle and occupied by a stronghold.It records the status using two-dimensional array.

The game test
In the process of programming, the programmer can directly click the Run Project icon on Eclipse toolbar and call the Android simulator to take simulated test on the game.The game interface is shown in Fig. 2.
Test process is as follows: after loading the tanks war game software the player can use the mouse to click startup icon of tanks war on the virtual machine.When the game page is started, the player can press the "OK" button to start the game.He can control their tanks.When the enemy tanks begin to appear, the player can use the virtual keyboard direction key or the keyboard direction key to control the direction and press the "OK" button to launch the bullet.When the player's tank was hit by a bullet or our home was destroyed by a bullet, game is over.

Fig2.the game interface
The game software function test includes the start of the game, exit, handling, the bullet trigger, statistical scores and other functions as well as the response to the mouse click events and key events.Through above test it get the following conclusion: the tanks war game software can realize the function of the tanks war games, friendly interface, easy to operate.After finishing the game development, the programmer can convert them to the APK document.He can install and execute them on Android emulator or an Android phone.

Conclusion
With the rapid development of the Android platform, all kinds of mobile games based on Android development emerge in endlessly.The development of mobile phone game based on Android system will focus on the construction of the Android development environment, the use of the Android game development technology, game plan, the design and implementation of game software.The software test result of tanks war mobile game shows that the software can realize the function of the system correctly and can successfully run on Android emulator and Android mobile phone.

4. 1 . 3
Android SDK Tool.The Android SDK tool is a software development kit.It provides a set of application software development tools for software development engineers to establish a particular software package, software framework, hardware platform, operating system.It is exclusive of the Android software development kit.Android SDK tools include Android emulator, Android development tools plugin for the Eclipse IDE, debug monitor service, Android debug bridge, Android asset packing tool, Android interface description language, sqlite database, Android virtual devices etc.