Вы находитесь на странице: 1из 23

ANDROID GAME

APPLICATION DEVELOPMENT

The same Image Finding

2015

Pai Chai University.


To fulfill the requirements for the degree of Bachelors
of Computer Science

Department of Computer Science


Professor: Kyunghee Lee

ANDROID GAME APPLICATION


DEVELOPMENT PROJECT

The same Image Finding

Name: Bandula Madusanka.


Student Number: 1383067.

ii

The professor Kyunghee Lee has examined the dissertation entitled: Android Game

Application Development (the same image finding android game) presented by Bandula
Madusanka Padmaperuma, a candidate for the degree of bachelor of Computer Science.
Adviser, Supervisor & Examiner: November, 2015

Kyunghee Lee
Professor
Department of Computer Science
Pai Chai University, South Korea.

Declaration of authorship
I hereby certify that this thesis and project I am submitting on the subject of android
programming. Also, this is entirely my own original works.

Signature of candidate:

iii

TABLE OF CONTENTS
Abstract.......................................................................................................................................
1. Introduction .............................................................................................................................
2. The progress of mobile game ..........................................................................................
2.1 Overview .......................................................................................................................
2.2 Soft-wear Platform for Mobile Applications ...............................................
2.3 Android ..........................................................................................................................
2.4 The Android Platform ..............................................................................................
2.5 Application frame work ..........................................................................................

v
1
2
2
4
5
5
6

3. Working principle of the application .........................................................................


3.1 Description .....................................................................................................................
3.2 The Animals & the Fruits Game...........................................................................
3.3 Logical Relation ..........................................................................................................

7
7
7
7

4. Game Operation ....................................................................................................................


4.1 Start Frame ....................................................................................................................
4.2 Game Choosing Frame ........................................................................................
4.3 Game Playing Frame .................................................................................................
4.4 Game Wining & Over Frame ..............................................................................

8
8
8
9
9

5. Instruction for the game .................................................................................................. 10


5.1 Instruction (How to play) ...................................................................................... 11
5.2 Screen Flow Chart ................................................................................................... 12
6. Implementation .................................................................................................................... 13
6.1 On Click Changeable Images .............................................................................. 23
7. Program Tests ....................................................................................................................... 14
7.1 Simulator Test .......................................................................................................... 14
7.2 Practical Mobile Phone Test ................................................................................ 15
8. Conclusion .............................................................................................................................. 16
9. Reference ................................................................................................................................. 17

iv

List of Figures

Figure 2.1 Global iOS &Android Time Spent per App Category ...................................................... 2
Figure 2.4 Android platform............................................................................................................................... 5
Figure 2.5 Activity life cycle ............................................................................................................................... 6
Figure 3.3 Logical relations ............................................................................................................................. 7
Figure 4.1 Start frame ........................................................................................................................................ 8
Figure 4.2 Game selection frame .................................................................................................................... 8
Figure 4.3 Game playing frames ..................................................................................................................... 9
Figure 4.4 Game wining frame ......................................................................................................................... 9
Figure 5.1 Game screen .................................................................................................................................... 10
Figure 5.2 Screen Flow Chart ......................................................................................................................... 12
Figure 6.1 On click event code ....................................................................................................................... 13
Figure 7.1 Emulator test .................................................................................................................................. 14
Figure 7.2 Practical mobile phone test ........................................................................................................ 15

List of Tables
Table 2.2 Market Shares of mobile operating system (CANALYS,2012) ........................................ 04
Table 7.1 Simulator Test .................................................................................................................................... 14
Table 7.2 Practical mobile phone test.......................................................................................................... 15

ABSTRACT
Today, mobile phones play an important role in our daily life. The reason is the
development of Smart Phones and mobile applications. People use smart phones because
smart phones are able to do a lot of things such as sending Emails, communication and
taking photos. With the development of the hardware of mobile phones, the quality and
popularity of smart phone games have increased. Android platform takes the biggest part
of the smart phone market. Therefore, the aim of my thesis and project is to get familiar
with Android smart phone and implement an application that can run on an actual Android
smart phone.
To achieve this aim, I have planned to develop a mobile phone game on Android
platform. The name of the game is the same image finding game. In this game, player
has to complete his android screen with the same images by clicking or touching his
phone. To build this game, I have used Android studio soft-wear (Android SDK), emulator
and actual android smart phone. Also, I have used JAVA, XML programing languages.
Keywords: Android, Android Studio, Android SDK, emulator, (JAVA, XML)

vi

1.

INTRODUCTION

The smart mobile phones have lots of functions such as sending E-mails, searching on
the internet, chatting, taking photos, recording videos, translating text and so on are some
typical application areas. However, mobile games are playing one of the most essential
roles in those functions. Especially, mobile games use as relaxation activities that you can
easily participate with your fingertips.
The trends of mobile phones are changing and evolving all the time. As a result of that, the
hardware of our mobile phone is getting more and more powerful today. Therefore, the games
have also become more and more attractive and realistic. However, the graphics are not the
only important issue for a game. Games are for playing, so the most important point of a
game is how to control the game. Usually, we used the keyboard to play the Snake.

Nowadays, we mainly play with touching the screen.

1.1 The Aim and Objectives of the Study


The aim of my project is to get familiar with Android mobile phone game development.
That is the reason why I decided to make a game application in this project. This game is
called the same image finding, the idea of this game is to improve players patient. In
this game, player has to complete the whole screen with the same images. When player
clicks one image button it is changing to a random image. So, player has to be patient in
order to win this game.

2. THE DEVELOPMENT OF MOBILE PHONE GAMES


2.1 Overview
With the development of communication and electronic technology in recent years,
smart phone has become a necessary device in our daily life. It is like an electronic wallet
that we have in our daily life. The reason is with the more powerful hardware and 4G, we
can almost do everything with our smart phone. However, it seems like that one function is
getting more interest, which is the games.
A pie chart in Figure 2.1 shows the percentage of time spent per application category
among Android and iOS smart phone owners.

Figure 2.1 : Global iOS &Android Time Spent per App Category

As we can see from Figure 2.1, games take up 43% percent of peoples smart phone
time. It is the biggest part among all categories of applications. Actually, this situation is
not only with those smart phones. I believe that all kinds of mobile phones have game
function, even the most basic phone. Therefore, everyone is able to play a game with their
mobile phone.
The main reason of this increase is the popularity of games and the lack of time for
recreational activities. As a result of those reasons, people trend to enjoy mobile games as
their recreation. For instance, in China, after a whole day work, most of the citizens have to
go back home by public transportations. So, what can people do while they are waiting for
a bus or taking a metro? The answer is that most of them play games. On the other hand,
because of the low capacity of network in crowded buses and subways, offline games have
further strengthened the top position of games. Therefore, mobile gaming has more users
and it is growing more rapidly than other platforms.
.

2.2 Software Platforms for Mobile Applications


A number of platforms have developed with the rise of the smartphone market and it is
worth looking closely at the development and distribution of applications for the most
popular and widespread platforms. The distribution of operating systems running on
smartphones sold in the second quarter of 2012 is compared to the second quarter of 2011
in Table 4.1. (Based on data from Canalys, an independent market research company).

Mobile platform

Market share 2nd Q 2012

Market share 2nd Q 2011

Alteration

Android

68.1 %

47.6 %

+ 20.5 %

iOS

16.4 %

18.9 %

- 2.5 %

BlackBerry

5.4 %

11.6 %

- 6.2 %

Symbian

4.1 %

16.8 %

- 12.7 %

Windows Phone

3.2. %

1.2 %

+2%

Others

2.9 %

3.9 %

-1%

Table 2.2: Market shares of mobile operating systems (CANALYS, 2012)

The market shares in Table 2.2 Indicate that the most smartphones were running with
an Android platform. Apple's iOS with 16.4 percent has fallen slightly against Android.
RIM's Blackberry and Symbian experienced a dramatic loss. Microsoft's Windows Phone
was able to gain more market shares and it is expected to grow further. The marketing
and advertising company Nielsen provides another analysis of market shares which show
that the situation on the United States smartphone market are in accordance with the
results from Canalys. According to their data published in June 2012 Android is running
on a majority of 51.8 percent of the smartphones owned in the United States and iOS has
a comparatively larger market share than worldwide with 34.3 percent. The other
platforms account for 14 percent altogether with 8.1 percent of devices that are running
BlackBerry. Therefore, it is essential to develop and learn more about android
applications for a big market.

2.3 Android
Android is a light-weight Linux-based open-source software platform. It has an operating
system, middleware, and key applications. It was developed for the use on mobile devices
under the leadership of Google and has become the most popular and widespread
operating system on smartphones. Developing applications for Android is possible for
anyone with basic knowledge of the Java programming language and all tools for software
development are available for free. Applications can be published on the Google Play Store.
For that, publisher requires an account which costs 25 U.S. dollars.

2.4 The Android Platform


Android is based on Linux Kernel and it is designed for the use on mobile devices like
smartphones and tablet computers. The Kernel provides hardware drivers for the display,
touch input, networking, power management and data storage. Furthermore, it contains
memory and process management components as well as a support for flash based file
systems like solid-state drives almost all mobile devices use instead of hard drives
(Helal/Bose/Li, 2012). Figure 2.4. Gives an overview of the Android platform.

Figure 2.4: Android platform


5

2.5 Application Framework

Application that displays an interface as a single screen page is called an Activity, which
is derived from the Android specific class Android.app.Activity. Hence, an application
usually consists of several Activity classes that handle functionalities like launching an
application or user input and evoke each other. Similar to other Android components, an

Activity class runs through different states which have corresponding class methods.
These states are called the Activity life cycle.

Figure 2.5: Activity life cycle

3. WORKING PRINCIPLE OF THE APPLICATION

3.1 Description
The game is named the same image finding game. The reason is player has to complete
his smart phone screen with same images in order to win this game.

3.2 The Animals Game & the Fruits Game


This is actually two types of game. Here, Player can select his game as he wants.

3.3 Logical Relation


If the first image and the final image are same, win screen going to appear. Which
means player is the winner.
Figure 3.3: Logical relations

Image 1

Image2

Image3

Image4

Image5

Image6

Image7

Image8

Image9

image10

4. GAME OPERATIONS
4.1 Start Frame
The frame 1 is used as a start frame. It is not a very important frame for this game.
However, it contains the name of the game. Additionally, the start frame also gives an
impression to the player (See Figure 4.1). Here, programmer uses click event as a
function. When player touches anywhere in the screen, the frame will go to select game
frame (game choosing frame).

Figure 4.1: Start frame

4.2 Game Choosing Frame


The frame 2 is used as a selective frame. It contains two types of games. If the player
wants to play Animal game, player can play animal game. Also, if the player wants to play
Fruits game, player can play fruits game.

Figure 4.2: Game selection frame

4.3 Game Playing Frame


The frame 3 and 4 are used as game playing Frames. In this frame, player going to play
game. Here, Player has to find the same images by clicking.

Figure 4.3: Game playing frames

4.4 Game Wining Frame


The frame 5 is used as a wining frame. If the player is able to complete the screen with
the same images, player is the winner. So, that time winning frame is going to appear.

Figure 4.4: Game wining frame

5. INSTRUCTION FOR THE GAME.


This game name is The Same Image Finding. When player open this app in his Android
phone, the game picture screen is going to appear. As soon as he clicks that screen, next
screen is going to open. In that screen, there are two buttons. First button is showing
Animal game. Second button is showing Fruit game. Here, player can select the game
as he prefer. Also, player is able to hear the background sound. After that, player directly
goes to the game screen then player is ready to play the game.

Figure 5: Game screen

10

5.1 Instruction (How to play).


There is an image in front and there are nine images in the bottom. Player needs to find
the right images by clicking those nine images. Also, it should be match with front image.

This
is
the
image that you
have to find.
You need to complete
whole screen by
clicking each image

Then after, player needs to click the front image. Then, winner screen going to
appear. Which means player has won the game.

After completing the


whole screen, you
need to click the front
image again.

Then, the winner


screen will display.

11

5.2 Screen Flow Chart.

Figure 5.2: Screen Flow Chart

12

6. IMPLEMENTATIONS
6.1 On Click Event (To change images)
This is the Java Code that I have used for On Click Action. Here, programmer uses click
event as a function. When a player is clicking an image button, image changes to random
image. Until player finds the right image, player has to click continuously.

final ImageButton ImageView1 = (ImageButton)


findViewById(R.id.imageView1);
final int imageId = (int) (Math.random() * imageIDs.length);
ImageView1.setBackgroundResource(imageIDs[imageId]);
ImageView1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {

if (event.getAction() == MotionEvent.ACTION_UP) {
Toast.makeText(getApplicationContext(),
"clicked ", Toast.LENGTH_SHORT).show();
a = (int) (Math.random() * imageIDs.length);
ImageView1.setBackgroundResource(imageIDs[a]);

}
return true;
}
});

Figure 6.1: On click event code

13

7. PROGRAM TESTS
After implementing the program, I tested the program in the two environments. First
using the simulator and second using a real phone.

7.1 Simulator Test


The testing environment that I used for simulator test was the same one that I used for
development. The description of used hardware is shown in Table 7.1.
Table 7:1 Simulator Test

Hardware

Laptop: hp
CPU: Intel i5 2430M
Memory: 4GB

Software

Android Studio,
Emulator

I tested the following functions:


Enter into game.
selecting game.
play game by
clicking. Restart.
Sound of the game.
The judgments of game over.(winning)
Figure 7.1: Emulator test

14

7.2 Practical Mobile Phone Test


The aim of my project was to make an android application which can run on a real
mobile phone. Therefore, the practical mobile phone test is necessary. The information of
the testing device is shown in Table 7.2.
Table 7.2: Practical mobile phone test.

Hardware

Mobile phone: Galaxy S


plus CPU: MSM8225T
(1.4GHz)

Platform

Android 2.3

I tested the same functions as in simulator test. Figure 7.2 shows the game while it is
running on the real mobile phone.

Figure 7.2: Practical mobile phone test


The result is that all the functions were working correctly. No problem on playing music
and the game does not run in the background after I quit it. In addition, the game
displayed smoothly on the testing device.

15

8. CONCLUSIONS
The aim of my final thesis is to develop an application for Android platform and test it on
an actual smart phone. As a result, I have developed the game which is called The Same
Image Finding. Actually, the result of the test proves that this game can successfully run
on an actual smart phone. Therefore, the aim is achieved.
Before I choose this topic, I did not know anything about Android application
programming. So, I took very long time to practice and learn how to develop an Android
application by using Android Studio soft-wear. Actually, there were lots of errors and
mistakes when I test by myself. However, after I overcame and finished this game, I really
learned lots of knowledge.
According to the limitation of the time. I am not able to implement more several of
functions in my game. Even though this game has met the requirements of the project
and it looks not bad. Finally, I want to make more interesting mode and some special
items in this game in the future.

16

9. REFERENCE.

Flurry Analytics-Time Spent Per Application Category [Referred 13/2/2013]


(http://news.xinhuanet.com/info/2013-01/30/c_132137699.htm )
The real time report. [Referred 14/2/2013]
(URL:http://therealtimereport.com/2012/06/12/mobile-gaming-torise-26-social-gaming-up-10-in- 2012/ )
(https://www.canalys.com/newsroom/stellar-growth-sees-china-take27-global-smart-phone-shipments-powered-domestic-vendors)
http://www.nielsen.com/us/en/insights.html
Android tutorial (www.guru.lk

)/ (www.tutorialspoit.com)

Beginning Android Application Development, Meng lee.


Android game development tutorials from Youtube (Lesson 1 to
Lesson)
Korean Book ( ).

17

Вам также может понравиться