# Lab 3: Google Map API, Game Logic (yay!) ## Tasks: 1. Sign-in Screen : Complete development of the Sign-in screen as explained in Lab2.txt & Lab2.png. 2. Play Fragment: Implement a simple UI (A banner image, greeting message, Play button) in the Fragment for the Play tab. You can use any banner image you like, but the size should be roughly the same as shown in Lab3.png and leave some space for the user info and play button. You'll need to connect to the server and retrieve your game data (the number of cats to find & pet, and, later, their approximate locations, see below), whereas the username can be retrieved from your local storage. Clicking the Play button will open the map activity. 3. Map Activity: Display a Google Map with the following markers - 1. Your current Location. 2. Locations where cats can be found. There should also be a status panel below the map. This panel will be: * empty, if no cat is selected---with a directive to the user to select a cat marker; * contain information on the selected cat. EXTRA CREDIT : For extra credit pre-select the cat closest to your location, and display information about that cat when the user opens the Map activity. 4. Google Map: You'll need a Google API Key that's authorized to use the Google Maps Android API. So **start early**, in case you hit any snags in the process of obtaining it! You can use SupportMapFragment (if you'd like to use Android Studio's backward-compatible defaults) or MapFragment (if you are not interested in compatibility with earlier SDKs) as a container for the Map, and access the Google Map Object through it. You'll need to zoom the map to a certain level, based on the current location or last known location. Experiment with zoom levels for the better game experience; you can add options to control the zoom level programmatically with additional buttons. There are two types of markers: the current location marker and cat markers. You need to draw the current location marker and constantly update it as you move around. The cat markers also need to be drawn on the map. The list of all cats can be retrieved from the server, including their names and their approximate latitude and longitude, URL of the cat images, and whether you have met & petted the cat. You have to calculate the distances from the current location and decide which ones to draw, because our logic is that user can only see cats within a certain range. This range will be set in your "Settings" tab, which you started designing in Lab 2. 5. Panel: The panel is for displaying cat info and the "Pet" (or "Pat" or "Feed"---be nice to these cats!) button. It shows a default message at the beginning. When the user clicks on the cat marker, the info about the corresponding cat will be shown in the panel. Once you are close enough to the approximate location of the cat, click the "Pet" button to send your coordinates to the server. The server will respond if whether you managed to pet the cat. (see server-protocol.txt for the format of queries and responses). 5. SuccessActivity: When you press the button from within a correct range of the cat, your app should send a request to the server to collect the achievement. If the server responds with a success message (see server-protocol.txt), launch a SuccessActivity. From the SuccessActivity you can go back to your home (TabbedLayout) or go back to looking for more cats. ## Terms and conditions: This assignment will be due next Thursday (October 26th) at 11:59 PM EST. Late assignments will get 10% credit docked for each day they are late. However, you will receive three (3) free 24-hour late submission passes for this course. Use them wisely. As usual, we will waive late penalties for extenuating circumstances such as travel and sickness (ask if in doubt). The user story below is intended as a general guidance to creating a sensible app interaction. Feel free to use your judgement as to what makes sense and is intuitive. Although you are free to explore third party libraries, the TAs will be able to provide limited help with issues with them. Extra credit will count for 20% of extra points. ## User Stories: This is only for the game part, user sign in/sign up is not included. 1. Supposing the user has already signed in, the first screen after opening the app will be the "Play" Fragment. 2. User will see a greeting (Hi, [Username]!) following the score. The user clicks on the start button to begin the game. 3. User clicks on the start button, the map activity is invoked. 4. The user sees her own location on the map as a marker and also sees the location of the cats in the area specified in the Settings tab. The user can then tap on one of the cat markers. This presents the information about the cat selected in the panel below the displayed map. The user can also see the "Pet" button on the panel, which is greyed-out and disabled if the user has already petted this cat before. Clicking on the button either shows either a Toast error message if the action was not successful or else takes the user to a "Success" screen as shown in Lab3.png. 5. From the success screen the user can either go back to the "Home" tabbed layout or begin the search for a new cat!