Post on 29-Apr-2018




2 download

Embed Size (px)


<ul><li><p>Treball de Fi de Grau </p><p>GRAU D'ENGINYERIA INFORMTICA </p><p>Facultat de Matemtiques </p><p>Universitat de Barcelona </p><p>M.M.O. GEOCACHING GAME </p><p>WITH MODULAR CONNECTIONS </p><p>Autor: Xavier Febrer Jord </p><p>Director: Eloi Puertas Prats </p><p>Realitzat a: Departament de Matemtica Aplicada i Anlisi. UB </p><p>Barcelona, 25 de juny de 2015 </p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>Table of Contents </p><p>1. Introduction </p><p>1.1. Project Overview </p><p>1.1.1. A Modern Approach </p><p>1.1.2. A Fast Introduction to Join The World </p><p>1.2. Motivation, Target Audience and Status </p><p>1.3. Requirements </p><p>2. Planification and Objectives </p><p>2.1. Software, Hardware and more Considerations </p><p>2.1.1. Device and Software Needs </p><p>2.2. First Approach </p><p>2.3. Iterations </p><p>2.4. Current Approach </p><p>3. Development </p><p>3.1. Logic and Protocol </p><p>3.1.1. Client Requests </p><p>3.1.2. Server Responses </p><p>3.1.3. Useful Libraries </p><p> GSON </p><p> Retrofit </p><p> Jersey </p><p>3.2. Server Structure </p><p>3.3. MongoDB </p><p>3.4. Android Client and Wear </p><p>4. Results and Tests </p><p>5. Future Steps and Conclusions </p><p>6. Bibliography </p><p>2 </p><p>2 </p><p>2 </p><p>4 </p><p>6 </p><p>8 </p><p>10 </p><p>10 </p><p>10 </p><p>11 </p><p>14 </p><p>15 </p><p>15 </p><p>15 </p><p>16 </p><p>21 </p><p>24 </p><p>24 </p><p>27 </p><p>28 </p><p>29 </p><p>30 </p><p>31 </p><p>34 </p><p>51 </p><p>53 </p><p>1</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>1. Introduction </p><p> M.M.O. Geocaching Game with Modular Connections - is a final grade project that </p><p>pretends to create a game for Android devices, where the users participate in a </p><p>massive multiplayer online experience in real time and located by GPS. </p><p>This project wants to be close to the new devices, services offered by other companies, </p><p>libraries,... to have an end product in the modern market, using concepts like </p><p>geocaching to narrow the distance between users using a synchronized and online </p><p>service. </p><p>1.1 Project Overview </p><p>1.1.1 A Modern Approach </p><p>The evolution of the society with technology, produces more users connected to the </p><p>Internet. The big difference between now and a couple of years ago, is that almost </p><p>every user has more than one device combining with a very easy access to it, tying the </p><p>basic needs of a sociable human. </p><p>For this, a little revolution in the computer world has happened, what was a static </p><p>multimedia center, work station, communication rules,... has just retired drastically. </p><p>With perspective, it can be seen that the appearance of the smartphones, as a heart of </p><p>our essential operations. like communication and the giant support that services from </p><p>other external companies available for everyone, made the desktop computers and </p><p>laptops to adapt to those services, evolving to a level of portability never seen in a </p><p>massive way in real life. Those devices adapted in a more usable physical form and the </p><p>2</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>software too, for example, the concept of cloud in the recent years, really pushed the </p><p>synchronization of the data to a really easy usable way in words of a developer. It can </p><p>be seen in tablets, laptops with the screen capable of the user touch, that those </p><p>evolutions derived from the previous computer stages. </p><p>There are some big examples of the software evolution that is not directly developed </p><p>for a desktop pc or laptop: </p><p>a. Clash of Clans is an MMO game only for mobile devices, where you control a </p><p>city and other real people can attack you, you can create online clans,... The </p><p>decisive thing is that is online, is one of the most played games in the world (so </p><p>you will encounter a lot of people and fast) and in addition you synchronize the </p><p>state of the game in the device you log in, meaning that the user will notice a </p><p>significantly less waste of time. </p><p>b. Whatsapp is an application that has a lot of popularity with more than 500 </p><p>Million users, puts all the people connected so easily, with 1 of cost per year </p><p>approximately and a 24 hour 365 days a year perfect service. This makes the </p><p>users join directly, rely on it, learn and remember the usability and the </p><p>company. </p><p>c. Google Play Services is a library for developers that provides the services of </p><p>Google to the users, that way the users can rely on a great company that </p><p>manages the email, the application data, all fast, secure and for free. On the </p><p>other hand, the developers can rely on a server that allows to store and retrieve </p><p>essential data and they do not have to maintain servers, which is really not very </p><p>desirable if you can avoid it so easily. </p><p>The usage of the cloud services, makes them good for processing data, and the </p><p>smartphones or other devices makes them a good client to receive it. This client-server </p><p>architecture is used in this project, because it needs a center of intelligence to </p><p>synchronize and process the data to harmonize the game. </p><p>3</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>If we go deeper, this project is divided in parts called modules and are easy to </p><p>identificate: server, Android client, Android Wear support client and a MongoDB </p><p>database. Other modules are planned and can be applied in the project: the module to </p><p>maintain the world populated of resources, an A.I. as a client or as an internal part of </p><p>the server, splitting the server into a request receiver and a request processor,... </p><p>The client of the project, needs to send location data to the server, any device that </p><p>knows how to get the position in the world and can access to the server, normally via </p><p>Internet, is able to run an application that can execute this projects protocol and play </p><p>with the other people in the game. </p><p>The game result of this, is still in evolution, it adapts to the ideology before and at least </p><p>has a clear idea of what is happening right now in the market and how to compete in </p><p>it. </p><p>1.1.2 A Fast Introduction to Join The World </p><p>In the game, each user has a unique account that resides in the server. Here is where </p><p>fantasy starts, in this account the user can create two characters, to play with them in </p><p>the world and choose a civilization: belong to the Othura, they are a future imperial </p><p>civilization and being a mage of their great magical legion is a respected position into </p><p>their society, otherwise the Slako civilization are a biologically evolved human empire, </p><p>that they know how to be strong when they are out there alone, specially their witches </p><p>with their magic. </p><p>4</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>Fig.1 Civilization selection. </p><p>Once a character has been selected, the game centers the character selected to the </p><p>users location and pretends to override the reality of the world with a fantasy map </p><p>combined: with the current real world map, with coins, keys, chests, portals, other real </p><p>player characters,... in a real time and obviously online. </p><p>To sum up, the selected character of the player appears in the world as a fantasy </p><p>character and the streets and cities are populated with objects and fantasy stuff. This </p><p>way, the user can play where it goes and can explore the world and leave its mark </p><p>capturing a portal for example. </p><p>5</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>Fig.2 Mage and Witch. </p><p>1.2 Motivation, Target Audience and Status </p><p>Currently, while exploring the possibilities that smartphones bring us, to replace things </p><p>that in the past were did in a different way and try to search for an improvement, in </p><p>time, in values,... the mobile device is one of the most important sectors of the planet. </p><p>The objective of this game is to innovate in new fields, having a clue of what other </p><p>games and services in general do, which show a greatly positive performance. </p><p>In addition, this project is an skeleton or some kind of SDK, where some modules can </p><p>be reused for other applications or they can be improved to increase the stability of </p><p>the core, because the more stability of the server has in this project, the more fluent </p><p>gameplay the users feel. </p><p>6</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>Fig.3 Popularity of the cloud synchronized applications. Data from Google Play. </p><p>This game is oriented approximately from teenagers to 30 year old people, because </p><p>the type of representation, visualization and gameplay, fits to the way of life of these </p><p>people. This population is very active in the world of smartphones and in particular </p><p>Android. </p><p>Currently, the state of the game is not final, neither it was thought to be in the future, </p><p>because the game evolve with its module structure, to achieve the good level of </p><p>stability for the audience. However, each revision or update can be a small release and </p><p>one small release can be a big release, considering the things that can be presented to </p><p>the users. </p><p>At the start of the project, a connection protocol was needed, and putting walls to the </p><p>development and to the modules was needed to concatenate the parts. </p><p>7</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>1.3 Requirements </p><p>To play this game, some approximate requirements are needed: </p><p>- Android: 4.2 minimum. </p><p>- CPU: dual-core 2.5 GHz minimum or quad-core with 2.3 minimum </p><p>recommended. </p><p>- RAM: 2GB minimum, 3GB-4GB recommended </p><p>- Storage: 50MB minimum, 100 recommended. </p><p>- GPS: needed. </p><p>- Accelerometer: needed. </p><p>- Magnetometer: needed. </p><p>If your device does not have this requirements the app is not assured to run well or </p><p>even run. </p><p>You can attach any smartwatch on the market considering a minimum of 512MB of </p><p>RAM and a Qualcomm Snapdragon 400 processor at least. The smartwatch is used to </p><p>represent data, so it wont perform big procedures during the game. The required </p><p>Android version of the smartwatch is 4.2 at least. </p><p>In the current version of the game, the battery and the internet connection is not </p><p>optimized, as it is a pre-alpha release, bugs can make a misuse of those sources. </p><p>The next lines of code must go inside the AndroidManifest.xml and inside the </p><p> tag: </p><p>8</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>These lines of code are permissions granted to the developer when publishing the </p><p>app. Without these permissions, the application will fail to execute. This way, when a </p><p>user installs the application, can see the resources used by the application and can </p><p>prevent malicious software to be installed in their device. </p><p>Mongo uses a server to provide a connection to the database, and that server can be </p><p>configured by following these easy steps: </p><p>http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/ </p><p>In this application, the MongoDB server listens to the port 20206. </p><p>After that the MongoDB Java library provides Objects maintain a connection to the </p><p>server in a form of a facade to provide an easy usage. </p><p>The Java server of this application can be reached by connecting to the server ip and </p><p>the hardcoded port value of 20202. </p><p>It is recommended to open the ports from 20200 to 20210 TCP/UDP to be able to </p><p>connect the different parts of the MongoDB to the server, and the server to the client. </p><p>To be able to work on the project, it is needed the latest Android Studio distribution </p><p>and the latest Eclipse with web plugin to open the respective Android Studio and </p><p>Eclipse Web projects. </p><p>9</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>2. Planification and Objectives </p><p> To follow and adapt to the changing world this project, as said in the introduction, </p><p>does not have a final release, it can have future periodic revisions and updates. Using </p><p>the ideology of Kanban as methodology to develop this project, it is viable to change to </p><p>Scrum or stay Kanban, it is compatible for the releases and for the development, </p><p>because for the people involved and the time remaining made Kanban the best </p><p>approach. </p><p>In the next sections, the procedures, tasks and decisions that were made in the past, </p><p>will be explained. </p><p>2.1 Software, Hardware and more Considerations </p><p>2.1.1 Device and software needs </p><p>For each user of the game, an Android smartphone device or an Android tablet as a </p><p>center element is used. Also an Android smartwatch is used to increase the game </p><p>experience as an optional element, which its functionality is to show the context of the </p><p>game and the data of the central device. It is needed to differentiate that Android </p><p>Wear is an extension of Android and it depends on a smartphone or a tablet to </p><p>complete its Android core functionality. </p><p>Thanks to the modular structure, the protocol of the game not only accept Android, </p><p>but also other applications for other platforms can be added to the project easily, if </p><p>the device agrees the requirements of the project, like an IPhone, Windows Phone or </p><p>even laptops. </p><p>10</p></li><li><p>M.M.O.GEOCACHINGGAMEWITHMODULARCONNECTIONSUniversitatdeBarcelona</p><p>For the software part, the connection between the user and the server is made by web </p><p>services. Currently it is used Java for all the client parts and the server, which uses a </p><p>Jersey library to make easy the requests received in the server. </p><p>Once the hardware and software needs are found, it must start the iteration of the </p><p>planification about the project. </p><p>2.2 First Approach </p><p>First of all, the first to think was that the project was implemented with a server, that </p><p>managed the world and users connected to the world, with an Android smartphone. </p><p>An Android smartwatch was considered from the beginning. </p><p>It was planified by parts and it was accorded that every two or three weeks, there will </p><p>be a revision and the planification will be revisited according to the requirements, the </p><p>look and feel of the current application, the remaining time,... </p><p>For this, the first revision was an application that regrouped...</p></li></ul>


View more >